Example usage for android.content.res ColorStateList valueOf

List of usage examples for android.content.res ColorStateList valueOf

Introduction

In this page you can find the example usage for android.content.res ColorStateList valueOf.

Prototype

@NonNull
public static ColorStateList valueOf(@ColorInt int color) 

Source Link

Usage

From source file:org.xbmc.kore.ui.RemoteFragment.java

@TargetApi(21)
private void adjustRemoteButtons() {
    Resources.Theme theme = getActivity().getTheme();
    TypedArray styledAttributes = theme.obtainStyledAttributes(
            new int[] { R.attr.remoteButtonColorFilter, R.attr.contentBackgroundColor });
    //                R.attr.remoteBackgroundColorFilter});
    Resources resources = getResources();
    int remoteButtonsColor = styledAttributes.getColor(styledAttributes.getIndex(0),
            resources.getColor(R.color.white)),
            remoteBackgroundColor = styledAttributes.getColor(styledAttributes.getIndex(1),
                    resources.getColor(R.color.dark_content_background_dim_70pct));
    styledAttributes.recycle();//from   w w w  .  j a  v  a  2s .  c om

    leftButton.setColorFilter(remoteButtonsColor);
    rightButton.setColorFilter(remoteButtonsColor);
    upButton.setColorFilter(remoteButtonsColor);
    downButton.setColorFilter(remoteButtonsColor);

    selectButton.setColorFilter(remoteButtonsColor);
    backButton.setColorFilter(remoteButtonsColor);
    infoButton.setColorFilter(remoteButtonsColor);
    osdButton.setColorFilter(remoteButtonsColor);
    contextButton.setColorFilter(remoteButtonsColor);

    // On ICS the remote background isn't shown as the tinting isn't supported
    //int backgroundResourceId = R.drawable.remote_background_square_black_alpha;
    int backgroundResourceId = R.drawable.remote_background_square_black;
    if (Utils.isLollipopOrLater()) {
        remotePanel.setBackgroundTintList(ColorStateList.valueOf(remoteBackgroundColor));
        remotePanel.setBackgroundResource(backgroundResourceId);
    } else if (Utils.isJellybeanOrLater()) {
        BitmapDrawable background = new BitmapDrawable(getResources(),
                BitmapFactory.decodeResource(getResources(), backgroundResourceId));
        background.setColorFilter(new PorterDuffColorFilter(remoteBackgroundColor, PorterDuff.Mode.SRC_IN));
        remotePanel.setBackground(background);
    }
}

From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Drawable createOverflowButtonBgLollipop(int pressedStateColor) {
    return new RippleDrawable(ColorStateList.valueOf(pressedStateColor), null, null);
}

From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java

@SuppressLint("NewApi")
private void adjustFab(boolean answerCorrect, int backgroundColor) {
    mSubmitAnswer.setChecked(answerCorrect);
    mSubmitAnswer.setBackgroundTintList(ColorStateList.valueOf(backgroundColor));
    mHideFabRunnable = new Runnable() {
        @Override//  w w w . jav  a2s .  c  om
        public void run() {
            mSubmitAnswer.hide();
        }
    };
    mHandler.postDelayed(mHideFabRunnable, ANSWER_HIDE_DELAY);
}

From source file:com.rks.musicx.ui.fragments.PlayingViews.Playing2Fragment.java

@Override
protected void function() {
    mPlayLayout.fastOpen();//ww  w . j  a va2 s. c  om
    mPlayLayout.getIvSkipNext().setImageResource(R.drawable.aw_ic_next);
    mPlayLayout.getIvSkipPrevious().setImageResource(R.drawable.aw_ic_prev);
    ateKey = Helper.getATEKey(getContext());
    accentColor = Config.accentColor(getContext(), ateKey);
    mPlayLayout.setPlayButtonBackgroundTintList(ColorStateList.valueOf(accentColor));
    moreMenu.setOnClickListener(mOnClickListener);
    if (getActivity() == null || getActivity().getWindow() == null) {
        return;
    }
    moreMenu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu));
    favhelper = new FavHelper(getContext());
    favButton.setOnClickListener(mOnClickListener);
    CustomLayoutManager customlayoutmanager = new CustomLayoutManager(getContext());
    customlayoutmanager.setOrientation(LinearLayoutManager.HORIZONTAL);
    queuerv.setLayoutManager(customlayoutmanager);
    SnapHelper startSnapHelper = new StartSnapHelper();
    startSnapHelper.attachToRecyclerView(queuerv);
    queuerv.setHasFixedSize(true);
    queueAdapter = new QueueAdapter(getContext(), this);
    queueAdapter.setLayoutId(R.layout.gridqueue);
    queuerv.setAdapter(queueAdapter);
    queueAdapter.setOnItemClickListener(onClick);
    ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(queueAdapter);
    mItemTouchHelper = new ItemTouchHelper(callback);
    mItemTouchHelper.attachToRecyclerView(queuerv);
    if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
        mPlayLayout.setProgressLineColor(ContextCompat.getColor(getContext(), R.color.translucent_white_8p));
    } else {
        mPlayLayout.setProgressLineColor(ContextCompat.getColor(getContext(), R.color.translucent_white_8p));
    }
    getActivity().getWindow().setStatusBarColor(accentColor);
    /**
     * Show Case
     */
    ShowcaseConfig config = new ShowcaseConfig();
    config.setDelay(500);
    MaterialShowcaseSequence sequence = new MaterialShowcaseSequence(getActivity(), "400");
    sequence.setConfig(config);
    sequence.addSequenceItem(queuerv, "Slide right/left to view Lyrics/PlayingView", "GOT IT");
    sequence.setOnItemDismissedListener(new MaterialShowcaseSequence.OnSequenceItemDismissedListener() {
        @Override
        public void onDismiss(MaterialShowcaseView materialShowcaseView, int i) {
            materialShowcaseView.hide();
        }
    });
    sequence.start();
    helper = new Helper(getContext());
    startVisualiser();
}

From source file:sg.fxl.topeka.widget.quiz.AbsQuizView.java

@SuppressLint("NewApi")
private void adjustFab(boolean answerCorrect, int backgroundColor) {
    submitAnswer.setChecked(answerCorrect);
    submitAnswer.setBackgroundTintList(ColorStateList.valueOf(backgroundColor));
    hideFabRunnable = new Runnable() {
        @Override/*from  w w w  .j  av  a  2s.  c o m*/
        public void run() {
            submitAnswer.hide();
        }
    };
    handler.postDelayed(hideFabRunnable, ANSWER_HIDE_DELAY);
}

From source file:com.philliphsu.bottomsheetpickers.date.BottomSheetDatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = super.onCreateView(inflater, container, savedInstanceState);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthDayYearView = (LinearLayout) view.findViewById(R.id.date_picker_month_day_year);
    mFirstTextView = (TextView) view.findViewById(R.id.date_picker_first_textview);
    mFirstTextView.setOnClickListener(this);
    mSecondTextView = (TextView) view.findViewById(R.id.date_picker_second_textview);
    mSecondTextView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
    }/*  w w  w  .j a v  a2  s .c o m*/

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this, mThemeDark);
    mYearPickerView = new YearPickerView(activity, this);
    mYearPickerView.setTheme(activity, mThemeDark);

    Resources res = getResources();
    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);

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

    mDoneButton = (FloatingActionButton) view.findViewById(R.id.done);
    mDoneButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(BottomSheetDatePickerDialog.this, mCalendar.get(Calendar.YEAR),
                        mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
            }
            dismiss();
        }
    });

    // Theme-specific configurations.
    if (mThemeDark) {
        // This is so the margin gets colored as well.
        view.setBackgroundColor(mDarkGray);
        mAnimator.setBackgroundColor(mDarkGray);
    } else {
        // Setup FAB icon color.
        Drawable fabIcon = mDoneButton.getDrawable();
        Utils.setTint(fabIcon, mAccentColor);
        mDoneButton.setImageDrawable(fabIcon);
    }

    // Configurations for both themes.
    View selectedDateLayout = view.findViewById(R.id.day_picker_selected_date_layout);
    selectedDateLayout.setBackgroundColor(mThemeDark ? mLightGray : mAccentColor);

    int white = ContextCompat.getColor(getActivity(), android.R.color.white);
    mDoneButton.setBackgroundTintList(ColorStateList.valueOf(mThemeDark ? mAccentColor : white));

    determineLocale_MD_Y_Indices();
    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);
    return view;
}

From source file:android.support.graphics.drawable.VectorDrawableCompat.java

public void setTint(int tint) {
    if (mDelegateDrawable != null) {
        DrawableCompat.setTint(mDelegateDrawable, tint);
        return;//from  ww w.  ja va2s  .c o m
    }

    setTintList(ColorStateList.valueOf(tint));
}

From source file:fr.outadev.skinswitch.DetailActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void colorRipple(int id, int tintColor) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        FloatingActionButton buttonView = (FloatingActionButton) findViewById(id);

        RippleDrawable ripple = (RippleDrawable) buttonView.getBackground();
        GradientDrawable rippleBackground = (GradientDrawable) ripple.getDrawable(0);
        rippleBackground.setColor(getResources().getColor(R.color.colorPrimary));

        ripple.setColor(ColorStateList.valueOf(tintColor));
    }/* w  w  w.j  av a2s . c  om*/
}

From source file:org.getlantern.firetweet.activity.support.SignInActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
    mResolver = getContentResolver();//from  w  ww .ja v  a 2  s  .  c  o  m
    mApplication = FiretweetApplication.getInstance(this);
    setContentView(R.layout.activity_sign_in);
    setSupportProgressBarIndeterminateVisibility(false);
    final long[] account_ids = getActivatedAccountIds(this);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(account_ids.length > 0);
    }

    if (savedInstanceState != null) {
        mAPIUrlFormat = savedInstanceState.getString(Accounts.API_URL_FORMAT);
        mAuthType = savedInstanceState.getInt(Accounts.AUTH_TYPE);
        mSameOAuthSigningUrl = savedInstanceState.getBoolean(Accounts.SAME_OAUTH_SIGNING_URL);
        mConsumerKey = trim(savedInstanceState.getString(Accounts.CONSUMER_KEY));
        mConsumerSecret = trim(savedInstanceState.getString(Accounts.CONSUMER_SECRET));
        mUsername = savedInstanceState.getString(Accounts.SCREEN_NAME);
        mPassword = savedInstanceState.getString(Accounts.PASSWORD);
        mAPIChangeTimestamp = savedInstanceState.getLong(EXTRA_API_LAST_CHANGE);
    }

    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/ProximaNova-Semibold.ttf");

    mSigninSignupContainer.setOrientation(
            mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);

    final Resources resources = getResources();
    final ColorStateList color = ColorStateList.valueOf(resources.getColor(R.color.material_light_blue));

    mSignInButton.setTextColor(Color.parseColor("#38c6f3"));
    mSignInButton.setBackgroundColor(Color.parseColor("#E7E7E7"));
    mSignInButton.setBackgroundResource(R.drawable.sign_in_btn);
    mSignInButton.setTypeface(font);
    mSignUpButton.setTypeface(font);
    poweredByButton.setTypeface(font);

    autoTweetCheckBox = (CheckBox) findViewById(R.id.autotweet_checkbox);
    autoTweetText = (TextView) findViewById(R.id.should_send_autotweet);

    // don't display the auto tweet text on subsequent runs
    if (mPreferences.contains(APP_RAN_BEFORE)) {
        autoTweetCheckBox.setVisibility(View.GONE);
        autoTweetText.setVisibility(View.GONE);
    } else {
        // the checkbox color attribute isn't a simple attribute
        // we have to grab the default checkbox and apply a color filter
        int id = Resources.getSystem().getIdentifier("btn_check_holo_light", "drawable", "android");
        Drawable drawable = ResourcesCompat.getDrawable(getResources(), id, null);
        if (drawable != null) {
            drawable.setColorFilter(Color.parseColor("white"), PorterDuff.Mode.SRC_ATOP);
            autoTweetCheckBox.setButtonDrawable(drawable);
        }

        autoTweetText.setTypeface(font);
        autoTweetText.setTextColor(Color.parseColor("white"));
    }

    setSignInButton();
}

From source file:com.achep.acdisplay.ui.components.MediaWidget.java

@SuppressLint("NewApi")
private void updatePlayPauseButtonColor(int color) {
    if (Device.hasLollipopApi()) {
        RippleDrawable2 rippleDrawable = (RippleDrawable2) mButtonPlayPause.getBackground();
        rippleDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
    } else {/*  w  ww.  jav a2  s . c o m*/
        RippleUtils.makeFor(ColorStateList.valueOf(color), false, mButtonPlayPause);
    }
}