Search in sources :

Example 6 with TypedArray

use of android.content.res.TypedArray in project philm by chrisbanes.

the class CollapsingTitleLayout method setTextAppearance.

public void setTextAppearance(int resId) {
    TypedArray atp = getContext().obtainStyledAttributes(resId, R.styleable.CollapsingTextAppearance);
    mTextPaint.setColor(atp.getColor(R.styleable.CollapsingTextAppearance_android_textColor, Color.WHITE));
    mCollapsedTitleTextSize = atp.getDimensionPixelSize(R.styleable.CollapsingTextAppearance_android_textSize, 0);
    atp.recycle();
    recalculate();
}
Also used : TypedArray(android.content.res.TypedArray)

Example 7 with TypedArray

use of android.content.res.TypedArray in project android-betterpickers by code-troopers.

the class CalendarDatePickerDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    if (getShowsDialog()) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }
    View view = inflater.inflate(R.layout.calendar_date_picker_dialog, container, false);
    mSelectedDateLayout = (LinearLayout) view.findViewById(R.id.day_picker_selected_date_layout);
    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);
    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_START));
        mMaxDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_END));
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
        mStyleResId = savedInstanceState.getInt(KEY_THEME);
        mDisabledDays = savedInstanceState.getSparseParcelableArray(KEY_DISABLED_DAYS);
    }
    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);
    Resources res = getResources();
    TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId, R.styleable.BetterPickersDialogs);
    mDayPickerDescription = res.getString(R.string.day_picker_description);
    mSelectDay = res.getString(R.string.select_day);
    mYearPickerDescription = res.getString(R.string.year_picker_description);
    mSelectYear = res.getString(R.string.select_year);
    int headerBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int preHeaderBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpPreHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int bodyBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpBodyBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    int buttonTextColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsTextColor, ContextCompat.getColor(getActivity(), R.color.bpBlue));
    mSelectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderSelectedTextColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
    mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderUnselectedTextColor, ContextCompat.getColor(getActivity(), R.color.radial_gray_light));
    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);
    Button doneButton = (Button) view.findViewById(R.id.done_button);
    if (mDoneText != null) {
        doneButton.setText(mDoneText);
    }
    doneButton.setTextColor(buttonTextColor);
    doneButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(CalendarDatePickerDialogFragment.this, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
    if (mCancelText != null) {
        cancelButton.setText(mCancelText);
    }
    cancelButton.setTextColor(buttonTextColor);
    cancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            dismiss();
        }
    });
    view.findViewById(R.id.ok_cancel_buttons_layout).setBackgroundColor(buttonBgColor);
    updateDisplay(false);
    setCurrentView(currentView);
    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }
    mHapticFeedbackController = new HapticFeedbackController(activity);
    mDayPickerView.setTheme(themeColors);
    mYearPickerView.setTheme(themeColors);
    mSelectedDateLayout.setBackgroundColor(headerBackgroundColor);
    mYearView.setBackgroundColor(headerBackgroundColor);
    mMonthAndDayView.setBackgroundColor(headerBackgroundColor);
    if (mDayOfWeekView != null) {
        mDayOfWeekView.setBackgroundColor(preHeaderBackgroundColor);
    }
    view.setBackgroundColor(bodyBgColor);
    mYearPickerView.setBackgroundColor(bodyBgColor);
    mDayPickerView.setBackgroundColor(bodyBgColor);
    return view;
}
Also used : Activity(android.app.Activity) View(android.view.View) TextView(android.widget.TextView) AlphaAnimation(android.view.animation.AlphaAnimation) Button(android.widget.Button) TypedArray(android.content.res.TypedArray) Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) OnClickListener(android.view.View.OnClickListener) HapticFeedbackController(com.codetroopers.betterpickers.HapticFeedbackController) Resources(android.content.res.Resources) CalendarDay(com.codetroopers.betterpickers.calendardatepicker.MonthAdapter.CalendarDay)

Example 8 with TypedArray

use of android.content.res.TypedArray in project android-betterpickers by code-troopers.

the class ExpirationPicker method setTheme.

/**
     * Change the theme of the Picker
     *
     * @param themeResId the resource ID of the new style
     */
public void setTheme(int themeResId) {
    mTheme = themeResId;
    if (mTheme != -1) {
        TypedArray a = getContext().obtainStyledAttributes(themeResId, R.styleable.BetterPickersDialogFragment);
        mTextColor = a.getColorStateList(R.styleable.BetterPickersDialogFragment_bpTextColor);
        mKeyBackgroundResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpKeyBackground, mKeyBackgroundResId);
        mButtonBackgroundResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpButtonBackground, mButtonBackgroundResId);
        mCheckDrawableSrcResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpCheckIcon, mCheckDrawableSrcResId);
        mTitleDividerColor = a.getColor(R.styleable.BetterPickersDialogFragment_bpTitleDividerColor, mTitleDividerColor);
        mKeyboardIndicatorColor = a.getColor(R.styleable.BetterPickersDialogFragment_bpKeyboardIndicatorColor, mKeyboardIndicatorColor);
        mDeleteDrawableSrcResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpDeleteIcon, mDeleteDrawableSrcResId);
    }
    restyleViews();
}
Also used : TypedArray(android.content.res.TypedArray)

Example 9 with TypedArray

use of android.content.res.TypedArray in project android-betterpickers by code-troopers.

the class ExpirationPickerDialogFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    if (args != null && args.containsKey(REFERENCE_KEY)) {
        mReference = args.getInt(REFERENCE_KEY);
    }
    if (args != null && args.containsKey(THEME_RES_ID_KEY)) {
        mTheme = args.getInt(THEME_RES_ID_KEY);
    }
    if (args != null && args.containsKey(MONTH_KEY)) {
        mMonthOfYear = args.getInt(MONTH_KEY);
    }
    if (args != null && args.containsKey(YEAR_KEY)) {
        mYear = args.getInt(YEAR_KEY);
    }
    if (args != null && args.containsKey(MINIMUM_YEAR_KEY)) {
        mMinimumYear = args.getInt(MINIMUM_YEAR_KEY);
    }
    setStyle(DialogFragment.STYLE_NO_TITLE, 0);
    // Init defaults
    mTextColor = getResources().getColorStateList(R.color.dialog_text_color_holo_dark);
    mDialogBackgroundResId = R.drawable.dialog_full_holo_dark;
    if (mTheme != -1) {
        TypedArray a = getActivity().getApplicationContext().obtainStyledAttributes(mTheme, R.styleable.BetterPickersDialogFragment);
        mTextColor = a.getColorStateList(R.styleable.BetterPickersDialogFragment_bpTextColor);
        mDialogBackgroundResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpDialogBackground, mDialogBackgroundResId);
    }
}
Also used : Bundle(android.os.Bundle) TypedArray(android.content.res.TypedArray)

Example 10 with TypedArray

use of android.content.res.TypedArray in project android-betterpickers by code-troopers.

the class HmsPickerDialogFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    if (args != null && args.containsKey(REFERENCE_KEY)) {
        mReference = args.getInt(REFERENCE_KEY);
    }
    if (args != null && args.containsKey(THEME_RES_ID_KEY)) {
        mTheme = args.getInt(THEME_RES_ID_KEY);
    }
    if (args != null && args.containsKey(PLUS_MINUS_VISIBILITY_KEY)) {
        mPlusMinusVisibility = args.getInt(PLUS_MINUS_VISIBILITY_KEY);
    }
    setStyle(DialogFragment.STYLE_NO_TITLE, 0);
    // Init defaults
    mTextColor = getResources().getColorStateList(R.color.dialog_text_color_holo_dark);
    mDialogBackgroundResId = R.drawable.dialog_full_holo_dark;
    if (mTheme != -1) {
        TypedArray a = getActivity().getApplicationContext().obtainStyledAttributes(mTheme, R.styleable.BetterPickersDialogFragment);
        mTextColor = a.getColorStateList(R.styleable.BetterPickersDialogFragment_bpTextColor);
        mDialogBackgroundResId = a.getResourceId(R.styleable.BetterPickersDialogFragment_bpDialogBackground, mDialogBackgroundResId);
    }
}
Also used : Bundle(android.os.Bundle) TypedArray(android.content.res.TypedArray)

Aggregations

TypedArray (android.content.res.TypedArray)1991 Paint (android.graphics.Paint)190 TypedValue (android.util.TypedValue)185 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)162 Resources (android.content.res.Resources)118 View (android.view.View)116 Drawable (android.graphics.drawable.Drawable)114 XmlResourceParser (android.content.res.XmlResourceParser)80 Context (android.content.Context)78 ColorStateList (android.content.res.ColorStateList)78 AttributeSet (android.util.AttributeSet)78 IOException (java.io.IOException)77 SuppressLint (android.annotation.SuppressLint)66 TextPaint (android.text.TextPaint)63 TextView (android.widget.TextView)62 ViewGroup (android.view.ViewGroup)59 Bundle (android.os.Bundle)48 LayoutInflater (android.view.LayoutInflater)42 Point (android.graphics.Point)41 ImageView (android.widget.ImageView)40