Example usage for android.content.res Resources getDimension

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

Introduction

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

Prototype

public float getDimension(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID.

Usage

From source file:com.manuelpeinado.numericpageindicator.NumericPageIndicator.java

@SuppressWarnings("deprecation")
public NumericPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) {
        return;//from w ww . j a  v a 2s .  com
    }

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultTextColor = res.getColor(R.color.default_page_number_indicator_text_color);
    final int defaultPageNumberTextColor = res
            .getColor(R.color.default_page_number_indicator_page_number_text_color);
    final boolean defaultPageNumberTextBold = res
            .getBoolean(R.bool.default_page_number_indicator_page_number_text_bold);
    final int defaultButtonPressedColor = res
            .getColor(R.color.default_page_number_indicator_pressed_button_color);
    final float defaultTopPadding = res.getDimension(R.dimen.default_page_number_indicator_top_padding);
    final float defaultBottomPadding = res.getDimension(R.dimen.default_page_number_indicator_bottom_padding);
    final float defaultTextSize = res.getDimension(R.dimen.default_page_number_indicator_text_size);
    final boolean defaultShowChangePageButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_change_page_buttons);
    final boolean defaultShowStartEndButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_start_end_buttons);
    final boolean defaultShowImagesForPageControls = res
            .getBoolean(R.bool.default_page_number_indicator_show_images_for_page_controls);

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

    mTextTemplate = a.getString(R.styleable.NumericPageIndicator_textTemplate);
    if (mTextTemplate == null) {
        mTextTemplate = res.getString(R.string.default_page_number_indicator_text_template);
        ;
    }
    parseTextTemplate();

    mTextStartButton = a.getString(R.styleable.NumericPageIndicator_startButtonText);
    if (mTextStartButton == null) {
        mTextStartButton = res.getString(R.string.default_page_number_indicator_start_button_text);
    }
    mTextEndButton = a.getString(R.styleable.NumericPageIndicator_endButtonText);
    if (mTextEndButton == null) {
        mTextEndButton = res.getString(R.string.default_page_number_indicator_end_button_text);
    }
    mTextPreviousButton = a.getString(R.styleable.NumericPageIndicator_previousButtonText);
    if (mTextPreviousButton == null) {
        mTextPreviousButton = res.getString(R.string.default_page_number_indicator_previous_button_text);
    }
    mTextNextButton = a.getString(R.styleable.NumericPageIndicator_nextButtonText);
    if (mTextNextButton == null) {
        mTextNextButton = res.getString(R.string.default_page_number_indicator_next_button_text);
    }

    // these will be null if they are unused
    mStartButtonImage = getBitmapFromDrawable(a.getDrawable(R.styleable.NumericPageIndicator_startButtonImage));
    mEndButtonImage = getBitmapFromDrawable(a.getDrawable(R.styleable.NumericPageIndicator_endButtonImage));
    mPreviousButtonImage = getBitmapFromDrawable(
            a.getDrawable(R.styleable.NumericPageIndicator_previousButtonImage));
    mNextButtonImage = getBitmapFromDrawable(a.getDrawable(R.styleable.NumericPageIndicator_nextButtonImage));

    mColorText = a.getColor(R.styleable.NumericPageIndicator_android_textColor, defaultTextColor);
    mColorPageNumberText = a.getColor(R.styleable.NumericPageIndicator_pageNumberTextColor,
            defaultPageNumberTextColor);
    mPageNumberTextBold = a.getBoolean(R.styleable.NumericPageIndicator_pageNumberTextBold,
            defaultPageNumberTextBold);
    mColorPressedButton = a.getColor(R.styleable.NumericPageIndicator_pressedButtonColor,
            defaultButtonPressedColor);
    mPaddingTop = a.getDimension(R.styleable.NumericPageIndicator_android_paddingTop, defaultTopPadding);
    mPaddingBottom = a.getDimension(R.styleable.NumericPageIndicator_android_paddingBottom,
            defaultBottomPadding);
    mPaintText.setColor(mColorText);
    mShowChangePageButtons = a.getBoolean(R.styleable.NumericPageIndicator_showChangePageButtons,
            defaultShowChangePageButtons);
    mShowStartEndButtons = a.getBoolean(R.styleable.NumericPageIndicator_showStartEndButtons,
            defaultShowStartEndButtons);
    mShowImagesForPageControls = a.getBoolean(R.styleable.NumericPageIndicator_showImagesForPageControls,
            defaultShowImagesForPageControls);

    mPaintButtonBackground.setColor(mColorPressedButton);
    final float textSize = a.getDimension(R.styleable.NumericPageIndicator_android_textSize, defaultTextSize);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);

    mPaintPageNumberText.setColor(mColorPageNumberText);
    mPaintPageNumberText.setTextSize(textSize);
    mPaintPageNumberText.setAntiAlias(true);
    if (mPageNumberTextBold) {
        mPaintPageNumberText.setTypeface(Typeface.DEFAULT_BOLD);
    }

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

    a.recycle();
}

From source file:com.android.contacts.ShortcutIntentBuilder.java

/**
 * Generates a phone number shortcut icon. Adds an overlay describing the type of the phone
 * number, and if there is a photo also adds the call action icon.
 *///  ww w .  java  2  s . co  m
private Bitmap generatePhoneNumberIcon(Drawable photo, int phoneType, String phoneLabel, int actionResId) {
    final Resources r = mContext.getResources();
    final float density = r.getDisplayMetrics().density;

    final Drawable phoneDrawable = r.getDrawableForDensity(actionResId, mIconDensity);
    // These icons have the same height and width so either is fine for the size.
    final Bitmap phoneIcon = BitmapUtil.drawableToBitmap(phoneDrawable, phoneDrawable.getIntrinsicHeight());

    Bitmap icon = generateQuickContactIcon(photo);
    Canvas canvas = new Canvas(icon);

    // Copy in the photo
    Paint photoPaint = new Paint();
    photoPaint.setDither(true);
    photoPaint.setFilterBitmap(true);
    Rect dst = new Rect(0, 0, mIconSize, mIconSize);

    // Create an overlay for the phone number type if we're pre-O. O created shortcuts have the
    // app badge which overlaps the type overlay.
    CharSequence overlay = Phone.getTypeLabel(r, phoneType, phoneLabel);
    if (!BuildCompat.isAtLeastO() && overlay != null) {
        TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
        textPaint.setTextSize(r.getDimension(R.dimen.shortcut_overlay_text_size));
        textPaint.setColor(r.getColor(R.color.textColorIconOverlay));
        textPaint.setShadowLayer(4f, 0, 2f, r.getColor(R.color.textColorIconOverlayShadow));

        final FontMetricsInt fmi = textPaint.getFontMetricsInt();

        // First fill in a darker background around the text to be drawn
        final Paint workPaint = new Paint();
        workPaint.setColor(mOverlayTextBackgroundColor);
        workPaint.setStyle(Paint.Style.FILL);
        final int textPadding = r.getDimensionPixelOffset(R.dimen.shortcut_overlay_text_background_padding);
        final int textBandHeight = (fmi.descent - fmi.ascent) + textPadding * 2;
        dst.set(0, mIconSize - textBandHeight, mIconSize, mIconSize);
        canvas.drawRect(dst, workPaint);

        overlay = TextUtils.ellipsize(overlay, textPaint, mIconSize, TruncateAt.END);
        final float textWidth = textPaint.measureText(overlay, 0, overlay.length());
        canvas.drawText(overlay, 0, overlay.length(), (mIconSize - textWidth) / 2,
                mIconSize - fmi.descent - textPadding, textPaint);
    }

    // Draw the phone action icon as an overlay
    int iconWidth = icon.getWidth();
    if (BuildCompat.isAtLeastO()) {
        // On O we need to calculate where the phone icon goes slightly differently. The whole
        // canvas area is 108dp, a centered circle with a diameter of 66dp is the "safe zone".
        // So we start the drawing the phone icon at
        // 108dp - 21 dp (distance from right edge of safe zone to the edge of the canvas)
        // - 24 dp (size of the phone icon) on the x axis (left)
        // The y axis is simply 21dp for the distance to the safe zone (top).
        // See go/o-icons-eng for more details and a handy picture.
        final int left = (int) (mIconSize - (45 * density));
        final int top = (int) (21 * density);
        canvas.drawBitmap(phoneIcon, left, top, photoPaint);
    } else {
        dst.set(iconWidth - ((int) (20 * density)), -1, iconWidth, ((int) (19 * density)));
        canvas.drawBitmap(phoneIcon, null, dst, photoPaint);
    }

    canvas.setBitmap(null);
    return icon;
}

From source file:com.inmobi.ultrapush.AnalyzeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    //  Debug.startMethodTracing("calc");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*from   ww  w. j  a  v a 2  s  .c o m*/

    DPRatio = getResources().getDisplayMetrics().density;

    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    Log.i(TAG, " max mem = " + maxMemory + "k");

    // set and get preferences in PreferenceActivity
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    // Set variable according to the preferences
    updatePreferenceSaved();

    textRMSChar = new char[getString(R.string.textview_RMS_text).length()];
    textCurChar = new char[getString(R.string.textview_cur_text).length()];
    textRecChar = new char[getString(R.string.textview_rec_text).length()];
    textPeakChar = new char[getString(R.string.textview_peak_text).length()];

    graphView = (AnalyzeView) findViewById(R.id.plot);

    // travel Views, and attach ClickListener to the views that contain android:tag="select"
    visit((ViewGroup) graphView.getRootView(), new Visit() {
        @Override
        public void exec(View view) {
            view.setOnLongClickListener(AnalyzeActivity.this);
            view.setOnClickListener(AnalyzeActivity.this);
            ((TextView) view).setFreezesText(true);
        }
    }, "select");

    Resources res = getResources();
    getAudioSourceNameFromIdPrepare(res);

    listItemTextSize = res.getDimension(R.dimen.button_text_fontsize);
    listItemTitleTextSize = res.getDimension(R.dimen.button_text_small_fontsize);

    /// initialize pop up window items list
    // http://www.codeofaninja.com/2013/04/show-listview-as-drop-down-android.html
    popupMenuSampleRate = popupMenuCreate(validateAudioRates(res.getStringArray(R.array.sample_rates)),
            R.id.button_sample_rate);
    popupMenuFFTLen = popupMenuCreate(res.getStringArray(R.array.fft_len), R.id.button_fftlen);
    popupMenuAverage = popupMenuCreate(res.getStringArray(R.array.fft_ave_num), R.id.button_average);

    mDetector = new GestureDetectorCompat(this, new AnalyzerGestureListener());

    setTextViewFontSize();
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java

private int calculateFabPadding(Context context) {
    Resources res = context.getResources();
    float scale = res.getDisplayMetrics().density;
    return (int) (res.getDimension(R.dimen.apptentive_message_center_bottom_padding) * scale + 0.5f);

}

From source file:com.xandy.calendar.AllInOneActivity.java

@Override
protected void onCreate(Bundle icicle) {
    if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) {
        setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
    }/*w  ww .ja va  2 s .c o m*/
    super.onCreate(icicle);

    if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) {
        mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS);
    }
    // Launch add google account if this is first time and there are no
    // accounts yet
    if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) {

        mHandler = new QueryHandler(this.getContentResolver());
        mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null,
                null /* selection args */, null /* sort order */);
    }

    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);

    // Get time from intent or icicle
    long timeMillis = -1;
    int viewType = -1;
    final Intent intent = getIntent();
    if (icicle != null) {
        timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
    } else {
        String action = intent.getAction();
        if (Intent.ACTION_VIEW.equals(action)) {
            // Open EventInfo later
            timeMillis = parseViewAction(intent);
        }

        if (timeMillis == -1) {
            timeMillis = Utils.timeFromIntentInMillis(intent);
        }
    }

    if (viewType == -1 || viewType > ViewType.MAX_VALUE) {
        viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
    }
    mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
    Time t = new Time(mTimeZone);
    t.set(timeMillis);

    if (DEBUG) {
        if (icicle != null && intent != null) {
            Log.d(TAG, "both, icicle:" + icicle.toString() + "  intent:" + intent.toString());
        } else {
            Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
        }
    }

    Resources res = getResources();
    mHideString = res.getString(R.string.hide_controls);
    mShowString = res.getString(R.string.show_controls);
    mOrientation = res.getConfiguration().orientation;
    if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width);
        if (mControlsParams == null) {
            mControlsParams = new LayoutParams(mControlsAnimateWidth, 0);
        }
        mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        // Make sure width is in between allowed min and max width values
        mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100,
                (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width));
        mControlsAnimateWidth = Math.min(mControlsAnimateWidth,
                (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width));
    }

    mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height);

    mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true);
    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
    mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
    mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
    mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen);
    mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
    mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time);
    Utils.setAllowWeekForDetailView(mIsMultipane);

    // setContentView must be called before configureActionBar
    setContentView(R.layout.all_in_one);

    if (mIsTabletConfig) {
        mDateRange = (TextView) findViewById(R.id.date_bar);
        mWeekTextView = (TextView) findViewById(R.id.week_num);
    } else {
        mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null);
    }

    // configureActionBar auto-selects the first tab you add, so we need to
    // call it before we set up our own fragments to make sure it doesn't
    // overwrite us
    configureActionBar(viewType);

    mHomeTime = (TextView) findViewById(R.id.home_time);
    mMiniMonth = findViewById(R.id.mini_month);
    if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
        mMiniMonth.setLayoutParams(
                new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight));
    }
    mCalendarsList = findViewById(R.id.calendar_list);
    mMiniMonthContainer = findViewById(R.id.mini_month_container);
    mSecondaryPane = findViewById(R.id.secondary_pane);

    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);

    initFragments(timeMillis, viewType, icicle);

    // Listen for changes that would require this to be refreshed
    SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);

    mContentResolver = getContentResolver();
}

From source file:com.example.test2969mediabrowser.UnderlinePageIndicator.java

public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//  w  w  w .  j  a  v a 2s .  com

    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));
    mColorSelected = a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor);//joe

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

    //==================joe add 20150918===============
    defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);//joe
    mPaintText.setTextSize(res.getDimension(R.dimen.default_title_indicator_text_size));
    mPaintText.setAntiAlias(true);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(defaultFooterLineHeight);
    mPaintFooterLine.setColor(getResources().getColor(R.color.blue_select));
    //==================joe add 20150918 end===============

    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);
}

From source file:com.blestep.sportsbracelet.view.TimelineChartView.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.tlcStepsFooterLabelColor);
    int barItemBg = ContextCompat.getColor(getContext(), R.color.tlcStepsBarItemBg);
    int highlightBarItemBg = ContextCompat.getColor(getContext(), R.color.tlcStepsHighlightBarItemBg);

    mBarItemBgPaint = new Paint();
    mBarItemBgPaint.setColor(barItemBg);
    mHighlightBarItemBgPaint = new Paint();
    mHighlightBarItemBgPaint.setColor(highlightBarItemBg);

    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);
    // /*  ww w.  j av a  2  s.  c om*/
    mGraphTargetDashedLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mGraphTargetDashedLinePaint.setStyle(Paint.Style.STROKE);
    mGraphTargetDashedLinePaint.setColor(Color.WHITE);
    mGraphTargetDashedLinePaint.setStrokeWidth(1);
    PathEffect pathEffect = new DashPathEffect(new float[] { 9, 3 }, 1);
    mGraphTargetDashedLinePaint.setPathEffect(pathEffect);

    // 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));
    }

    // 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:com.google.android.apps.forscience.whistlepunk.RunReviewOverlay.java

private void init() {
    Resources res = getResources();

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);

    mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDotPaint.setStyle(Paint.Style.FILL);

    mDotBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDotBackgroundPaint.setColor(res.getColor(R.color.chart_margins_color));
    mDotBackgroundPaint.setStyle(Paint.Style.FILL);

    Typeface valueTypeface = Typeface.create("sans-serif-medium", Typeface.NORMAL);
    Typeface timeTimeface = Typeface.create("sans-serif", Typeface.NORMAL);

    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setTypeface(valueTypeface);
    mTextPaint.setTextSize(res.getDimension(R.dimen.run_review_overlay_label_text_size));
    mTextPaint.setColor(res.getColor(R.color.text_color_white));

    mTimePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTimePaint.setTypeface(timeTimeface);
    mTimePaint.setTextSize(res.getDimension(R.dimen.run_review_overlay_label_text_size));
    mTimePaint.setColor(res.getColor(R.color.text_color_white));

    mCenterLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCenterLinePaint.setStrokeWidth(res.getDimensionPixelSize(R.dimen.chart_grid_line_width));
    mCenterLinePaint.setStyle(Paint.Style.STROKE);
    mCenterLinePaint.setColor(res.getColor(R.color.text_color_white));

    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setStrokeWidth(res.getDimensionPixelSize(R.dimen.recording_overlay_bar_width));
    int dashSize = res.getDimensionPixelSize(R.dimen.run_review_overlay_dash_size);
    mLinePaint.setPathEffect(new DashPathEffect(new float[] { dashSize, dashSize }, dashSize));
    mLinePaint.setColor(res.getColor(R.color.note_overlay_line_color));
    mLinePaint.setStyle(Paint.Style.STROKE);

    mPath = new Path();

    // TODO: Need to make sure this is at least as detailed as the SensorAppearance number
    // format!/*from   w  w w.j  a v a  2 s  . c  om*/
    mTextFormat = res.getString(R.string.run_review_chart_label_format);
    mTimeFormat = ElapsedTimeAxisFormatter.getInstance(getContext());

    mCropBackgroundPaint = new Paint();
    mCropBackgroundPaint.setStyle(Paint.Style.FILL);
    mCropBackgroundPaint.setColor(res.getColor(R.color.text_color_black));
    mCropBackgroundPaint.setAlpha(40);

    mCropVerticalLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCropVerticalLinePaint.setStyle(Paint.Style.STROKE);
    mCropVerticalLinePaint.setStrokeWidth(res.getDimensionPixelSize(R.dimen.chart_grid_line_width));
}

From source file:com.android.calendar.AllInOneActivity.java

@Override
protected void onCreate(Bundle icicle) {
    if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) {
        setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
    }/*from   www.  j  a  v  a  2  s. c  o m*/
    super.onCreate(icicle);
    dynamicTheme.onCreate(this);

    if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) {
        mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS);
    }
    // Launch add google account if this is first time and there are no
    // accounts yet
    if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) {

        mHandler = new QueryHandler(this.getContentResolver());
        mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null,
                null /* selection args */, null /* sort order */);
    }

    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);

    // Check and ask for most needed permissions
    checkAppPermissions();

    // Get time from intent or icicle
    long timeMillis = -1;
    int viewType = -1;
    final Intent intent = getIntent();
    if (icicle != null) {
        timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
    } else {
        String action = intent.getAction();
        if (Intent.ACTION_VIEW.equals(action)) {
            // Open EventInfo later
            timeMillis = parseViewAction(intent);
        }

        if (timeMillis == -1) {
            timeMillis = Utils.timeFromIntentInMillis(intent);
        }
    }

    if (viewType == -1 || viewType > ViewType.MAX_VALUE) {
        viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
    }
    mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
    Time t = new Time(mTimeZone);
    t.set(timeMillis);

    if (DEBUG) {
        if (icicle != null && intent != null) {
            Log.d(TAG, "both, icicle:" + icicle.toString() + "  intent:" + intent.toString());
        } else {
            Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
        }
    }

    Resources res = getResources();
    mHideString = res.getString(R.string.hide_controls);
    mShowString = res.getString(R.string.show_controls);
    mOrientation = res.getConfiguration().orientation;
    if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width);
        if (mControlsParams == null) {
            mControlsParams = new LayoutParams(mControlsAnimateWidth, 0);
        }
        mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        // Make sure width is in between allowed min and max width values
        mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100,
                (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width));
        mControlsAnimateWidth = Math.min(mControlsAnimateWidth,
                (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width));
    }

    mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height);

    mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true);
    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
    mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
    mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
    mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen);
    mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
    mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time);
    Utils.setAllowWeekForDetailView(mIsMultipane);

    // setContentView must be called before configureActionBar
    setContentView(R.layout.all_in_one_material);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mNavigationView = (NavigationView) findViewById(R.id.navigation_view);

    mFab = (FloatingActionButton) findViewById(R.id.floating_action_button);

    if (mIsTabletConfig) {
        mDateRange = (TextView) findViewById(R.id.date_bar);
        mWeekTextView = (TextView) findViewById(R.id.week_num);
    } else {
        mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null);
    }

    setupToolbar(viewType);
    setupNavDrawer();
    setupFloatingActionButton();

    mHomeTime = (TextView) findViewById(R.id.home_time);
    mMiniMonth = findViewById(R.id.mini_month);
    if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
        mMiniMonth.setLayoutParams(
                new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight));
    }
    mCalendarsList = findViewById(R.id.calendar_list);
    mMiniMonthContainer = findViewById(R.id.mini_month_container);
    mSecondaryPane = findViewById(R.id.secondary_pane);

    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);

    initFragments(timeMillis, viewType, icicle);

    // Listen for changes that would require this to be refreshed
    SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);

    mContentResolver = getContentResolver();
}

From source file:com.android.gallery3d.filtershow.FilterShowActivity.java

private void setDefaultValues() {
    Resources res = getResources();

    // TODO: get those values from XML.
    FramedTextButton.setTextSize((int) getPixelsFromDip(14));
    FramedTextButton.setTrianglePadding((int) getPixelsFromDip(4));
    FramedTextButton.setTriangleSize((int) getPixelsFromDip(10));

    Drawable curveHandle = res.getDrawable(R.drawable.camera_crop);
    int curveHandleSize = (int) res.getDimension(R.dimen.crop_indicator_size);
    Spline.setCurveHandle(curveHandle, curveHandleSize);
    Spline.setCurveWidth((int) getPixelsFromDip(3));

    mOriginalImageUri = null;// w w  w  .  j a v  a2 s  . co m
}