Java Code Examples for android.support.design.widget.FloatingActionButton#setBackgroundTintList()

The following examples show how to use android.support.design.widget.FloatingActionButton#setBackgroundTintList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FabSpeedDial.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
private void setupFab() {
    // Set up the client's FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setImageDrawable(fabDrawable);
    if (Utils.hasLollipop()) {
        fab.setImageTintList(fabDrawableTint);
    }
    if (fabBackgroundTint != null) {
        fab.setBackgroundTintList(fabBackgroundTint);
    }

    fab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAnimating) return;

            if (isMenuOpen()) {
                closeMenu();
            } else {
                openMenu();
            }
        }
    });
}
 
Example 2
Source File: IncDecCircular.java    From IncDec with Apache License 2.0 6 votes vote down vote up
/** Setting up the left button */
private void setupLeftButton(FloatingActionButton leftButton, Drawable leftSrc,
                             int leftButtonTint, int leftDrawableTint) {
    if(leftSrc!=null) {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            leftSrc.setTintList(new ColorStateList(new int[][]{new int[]{0}},
                    new int[]{leftDrawableTint}));
        }
        else
        {
            final Drawable wrappedDrawable = DrawableCompat.wrap(leftSrc);
            DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(leftDrawableTint));
        }
        leftButton.setImageDrawable(leftSrc);

    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        leftButton.setBackgroundTintList(new ColorStateList(new int[][]{new int[]{0}},
                new int[]{leftButtonTint}));
    }
    else
    {
        ViewCompat.setBackgroundTintList(leftButton, ColorStateList.valueOf(leftButtonTint));
    }

}
 
Example 3
Source File: IncDecCircular.java    From IncDec with Apache License 2.0 6 votes vote down vote up
/** Setting up the right button */
private void setupRightButton(FloatingActionButton rightButton, Drawable rightSrc,
                              int rightButtonTint, int rightDrawableTint) {
    if(rightSrc!=null) {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            rightSrc.setTintList(new ColorStateList(new int[][]{new int[]{0}},
                    new int[]{rightDrawableTint}));
        }
        else
        {
            final Drawable wrappedDrawable = DrawableCompat.wrap(rightSrc);
            DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(rightDrawableTint));
        }
        rightButton.setImageDrawable(rightSrc);
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        rightButton.setBackgroundTintList(new ColorStateList(new int[][]{new int[]{0}},
                new int[]{rightButtonTint}));
    }
    else
    {
        ViewCompat.setBackgroundTintList(rightButton, ColorStateList.valueOf(rightButtonTint));
    }
}
 
Example 4
Source File: ContactPickerActivity.java    From UnifiedContactPicker with Apache License 2.0 6 votes vote down vote up
private void setFAB() {
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    if(fabColor != null)
        fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(fabColor)));
    if(fabDrawable != null){
        Bitmap customFabIcon = PickerUtils.extractDrawable(fabDrawable);
        if(customFabIcon != null)
            fab.setImageBitmap(customFabIcon);
    }

    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TreeSet<SimpleContact> selected = mFragment.getSelected();
            Intent result = new Intent();
            result.putExtra(CP_SELECTED_CONTACTS, selected);
            setResult(RESULT_OK,result);
            finish();
        }
    });
}
 
Example 5
Source File: FabSpeedDial.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
private void setupFab() {
    // Set up the client's FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setImageDrawable(fabDrawable);
    if (Utils.hasLollipop()) {
        fab.setImageTintList(fabDrawableTint);
    }
    if (fabBackgroundTint != null) {
        fab.setBackgroundTintList(fabBackgroundTint);
    }

    fab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAnimating) return;

            if (isMenuOpen()) {
                closeMenu();
            } else {
                openMenu();
            }
        }
    });
}
 
Example 6
Source File: CategoryFeedsFragment.java    From SimpleNews with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.feed_selection, container, false);
    feedListView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
    feedListView.setLayoutManager(new LinearLayoutManager(inflater.getContext()));
    FloatingActionButton button = (FloatingActionButton) rootView.findViewById(R.id.add_button);
    button.setBackgroundTintList(new ColorStateList(new int[][]{new int[]{0}}, new int[]{PrefUtilities.getInstance().getCurrentColor()}));
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            createFeedClicked();
        }
    });

    initAdapter();
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (activity != null) {
        ActionBar ab = activity.getSupportActionBar();
        if (ab != null) {
            ab.setDisplayHomeAsUpEnabled(true);
        }
    }

    return rootView;
}
 
Example 7
Source File: FabSpeedDial.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
/**
 * Applies a tint to the background drawable. Does not modify the current tint
 * mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
 *
 * @param tint the tint to apply, may be {@code null} to clear tint
 */
public void setSecondaryBackgroundTintList(@Nullable ColorStateList tint) {
    if (miniFabBackgroundTint != tint) {
        miniFabBackgroundTint = tint;
        for(FloatingActionButton miniFab : fabMenuItemMap.keySet()) {
            miniFab.setBackgroundTintList(tint);
        }
    }
}
 
Example 8
Source File: MultiFloatingActionButton.java    From ReadMark with Apache License 2.0 5 votes vote down vote up
private void setBaseViews(Context context){
    mBackgroundView = new View(context);
    mBackgroundView.setBackgroundColor(mBackgroundColor);
    mBackgroundView.setAlpha(0);
    addView(mBackgroundView);

    mFloatingActionButton = new FloatingActionButton(context);
    mFloatingActionButton.setBackgroundTintList(mFabColor);
    mFloatingActionButton.setImageDrawable(mFabIcon);
    addView(mFloatingActionButton);
}
 
Example 9
Source File: MultiFloatingActionButton.java    From ReadMark with Apache License 2.0 5 votes vote down vote up
private void setBaseViews(Context context){
    mBackgroundView = new View(context);
    mBackgroundView.setBackgroundColor(mBackgroundColor);
    mBackgroundView.setAlpha(0);
    addView(mBackgroundView);

    mFloatingActionButton = new FloatingActionButton(context);
    mFloatingActionButton.setBackgroundTintList(mFabColor);
    mFloatingActionButton.setImageDrawable(mFabIcon);
    addView(mFloatingActionButton);
}
 
Example 10
Source File: MDTintUtil.java    From UGank with GNU General Public License v3.0 5 votes vote down vote up
public static void setTint(@NonNull FloatingActionButton floatingActionButton, @ColorInt int color) {
    int[] colors = new int[]{color, color, color, color, color, color};
    int[][] states = new int[6][];
    states[0] = new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled};
    states[1] = new int[]{android.R.attr.state_enabled, android.R.attr.state_focused};
    states[2] = new int[]{android.R.attr.state_enabled};
    states[3] = new int[]{android.R.attr.state_focused};
    states[4] = new int[]{android.R.attr.state_window_focused};
    states[5] = new int[]{};
    floatingActionButton.setBackgroundTintList(new ColorStateList(states, colors));
}
 
Example 11
Source File: BaseActivity.java    From MicroReader with MIT License 5 votes vote down vote up
public int setToolBar(FloatingActionButton floatingActionButton, Toolbar toolbar, boolean isChangeToolbar, boolean isChangeStatusBar, DrawerLayout drawerLayout) {
    int vibrantColor = getSharedPreferences(SharePreferenceUtil.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).getInt(SharePreferenceUtil.VIBRANT, 0);
    int mutedColor = getSharedPreferences(SharePreferenceUtil.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).getInt(SharePreferenceUtil.MUTED, 0);
    if (Config.isNight) {
        vibrantColor = Color.BLACK;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (SharePreferenceUtil.isChangeNavColor(this))
            getWindow().setNavigationBarColor(vibrantColor);
        else
            getWindow().setNavigationBarColor(Color.BLACK);
    }
    if (floatingActionButton != null)
        floatingActionButton.setBackgroundTintList(ColorStateList.valueOf(mutedColor));
    if (isChangeToolbar)
        toolbar.setBackgroundColor(vibrantColor);
    if (isChangeStatusBar) {
        if (SharePreferenceUtil.isImmersiveMode(this))
            StatusBarUtil.setColorNoTranslucent(this, vibrantColor);
        else
            StatusBarUtil.setColor(this, vibrantColor);
    }
    if (drawerLayout != null) {
        if (SharePreferenceUtil.isImmersiveMode(this))
            StatusBarUtil.setColorNoTranslucentForDrawerLayout(this, drawerLayout, vibrantColor);
        else
            StatusBarUtil.setColorForDrawerLayout(this, drawerLayout, vibrantColor);
    }
    return vibrantColor;
}
 
Example 12
Source File: FabSpeedDial.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);
    if (Utils.hasLollipop()) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}
 
Example 13
Source File: FabSpeedDial.java    From fab-speed-dial with Apache License 2.0 4 votes vote down vote up
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);

        if (miniFabTitleTextColorArray != null) {
            titleView.setTextColor(ContextCompat.getColorStateList(getContext(),
                    miniFabTitleTextColorArray[menuItem.getOrder()]));
        }
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);

    if (miniFabBackgroundTintArray != null) {
        miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(),
                miniFabBackgroundTintArray[menuItem.getOrder()]));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}
 
Example 14
Source File: FabSpeedDial.java    From fab-speed-dial with Apache License 2.0 4 votes vote down vote up
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    LayoutParams layoutParams =
            new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    int coordinatorLayoutOffset = getResources().getDimensionPixelSize(R.dimen.coordinator_layout_offset);
    if (fabGravity == BOTTOM_END || fabGravity == TOP_END) {
        layoutParams.setMargins(0, 0, coordinatorLayoutOffset, 0);
    } else {
        layoutParams.setMargins(coordinatorLayoutOffset, 0, 0, 0);
    }
    menuItemsLayout.setLayoutParams(layoutParams);

    // Set up the client's FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setImageDrawable(fabDrawable);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fab.setImageTintList(fabDrawableTint);
    }
    if (fabBackgroundTint != null) {
        fab.setBackgroundTintList(fabBackgroundTint);
    }

    fab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAnimating) return;

            if (isMenuOpen()) {
                closeMenu();
            } else {
                openMenu();
            }
        }
    });

    // Needed in order to intercept key events
    setFocusableInTouchMode(true);

    if (useTouchGuard) {
        ViewParent parent = getParent();

        touchGuard = new View(getContext());
        touchGuard.setOnClickListener(this);
        touchGuard.setWillNotDraw(true);
        touchGuard.setVisibility(GONE);

        if (touchGuardDrawable != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                touchGuard.setBackground(touchGuardDrawable);
            } else {
                touchGuard.setBackgroundDrawable(touchGuardDrawable);
            }
        }

        if (parent instanceof FrameLayout) {
            FrameLayout frameLayout = (FrameLayout) parent;
            frameLayout.addView(touchGuard);
            bringToFront();
        } else if (parent instanceof CoordinatorLayout) {
            CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
            coordinatorLayout.addView(touchGuard);
            bringToFront();
        } else if (parent instanceof RelativeLayout) {
            RelativeLayout relativeLayout = (RelativeLayout) parent;
            relativeLayout.addView(touchGuard,
                    new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                            ViewGroup.LayoutParams.MATCH_PARENT));
            bringToFront();
        } else {
            Log.d(TAG, "touchGuard requires that the parent of this FabSpeedDialer be a FrameLayout or RelativeLayout");
        }
    }

    setOnClickListener(this);

    if (shouldOpenMenu)
        openMenu();
}
 
Example 15
Source File: BaseAudioView.java    From audioview with Boost Software License 1.0 4 votes vote down vote up
protected void init(@Nullable Context context, AttributeSet attrs) {
    if (isInEditMode())
        return;

    if (context != null && attrs != null) {
        TypedArray styleable = context.obtainStyledAttributes(attrs, R.styleable.BaseAudioView, 0, 0);
        mShowTitle = styleable.getBoolean(R.styleable.BaseAudioView_showTitle, true);
        mSelectControls = styleable.getBoolean(R.styleable.BaseAudioView_selectControls, true);
        mMinified = styleable.getBoolean(R.styleable.BaseAudioView_minified, false);
        mCustomLayoutRes = styleable.getResourceId(R.styleable.BaseAudioView_customLayout, 0);
        mCustomPlayIconRes = styleable.getResourceId(R.styleable.BaseAudioView_customPlayIcon,
                R.drawable.ic_play_arrow_white_24dp);
        mCustomPauseIconRes = styleable.getResourceId(R.styleable.BaseAudioView_customPauseIcon,
                R.drawable.ic_pause_white_24dp);

        if (styleable.hasValue(R.styleable.BaseAudioView_primaryColor))
            mPrimaryColor = styleable.getColor(R.styleable.BaseAudioView_primaryColor, 0xFF000000);

        if (styleable.hasValue(R.styleable.BaseAudioView_minified) && mCustomLayoutRes != 0) {
            throw new RuntimeException("Minified attr should not be specified while using custom layout.");
        }
        styleable.recycle();
    }

    int layout;

    if (mCustomLayoutRes != 0) {
        layout = mCustomLayoutRes;
    } else {
        layout = mMinified ? R.layout.audioview_min : R.layout.audioview;
    }
    View view = inflate(getContext(), layout, null);
    addView(view);

    mPlay = findViewById(R.id.play);
    mRewind = findViewById(R.id.rewind);
    mForward = findViewById(R.id.forward);
    if (!mSelectControls) {
        if (mRewind != null)
            mRewind.setVisibility(GONE);
        if (mForward != null)
            mForward.setVisibility(GONE);
    }
    mProgress = findViewById(R.id.progress);
    mIndeterminate = findViewById(R.id.indeterminate);
    mTitle = findViewById(R.id.title);
    if (mTitle != null) {
        mTitle.setSelected(true);
        mTitle.setMovementMethod(new ScrollingMovementMethod());
        if (!mShowTitle)
            mTitle.setVisibility(GONE);
    }
    mTime = findViewById(R.id.time);
    mTotalTime = findViewById(R.id.total_time);
    mPlay.setOnClickListener(this);
    if (mRewind != null)
        mRewind.setOnClickListener(this);
    if (mForward != null)
        mForward.setOnClickListener(this);

    if (mPrimaryColor != 0) {
        mProgress.getProgressDrawable().setColorFilter(mPrimaryColor, PorterDuff.Mode.MULTIPLY);
        mIndeterminate.getIndeterminateDrawable().setColorFilter(mPrimaryColor, PorterDuff.Mode.SRC_ATOP);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            mProgress.getThumb().setColorFilter(mPrimaryColor, PorterDuff.Mode.SRC_ATOP);
        } else {
            Drawable thumb = ContextCompat.getDrawable(getContext(), R.drawable.thumb);
            if (thumb != null) {
                thumb.setColorFilter(mPrimaryColor, PorterDuff.Mode.SRC_ATOP);
                mProgress.setThumb(thumb);
            }
        }

        if (mPlay instanceof FloatingActionButton) {
            FloatingActionButton mPlayFloating = (FloatingActionButton) mPlay;
            mPlayFloating.setBackgroundTintList(ColorStateList.valueOf(mPrimaryColor));
            mPlayFloating.setRippleColor(darkenColor(mPrimaryColor, 0.87f));
        }
    }
}
 
Example 16
Source File: FABColorAdapter.java    From Scoops with Apache License 2.0 4 votes vote down vote up
@Override
public void applyColor(FloatingActionButton view, @ColorInt int color) {
    ColorStateList colorStateList = Utils.colorToStateList(color);
    view.setBackgroundTintList(colorStateList);
}
 
Example 17
Source File: WebViewFragment.java    From 4pdaClient-plus with Apache License 2.0 4 votes vote down vote up
public void setFabColors(final FloatingActionButton fab){
    fab.setBackgroundTintList(ColorStateList.valueOf(AppTheme.getColorAccent("Accent")));
    fab.setRippleColor(AppTheme.getColorAccent("Pressed"));
}
 
Example 18
Source File: PlayLayout.java    From PlayWidget with MIT License 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {

        LayoutInflater.from(context).inflate(R.layout.pw_reveal_view_content, this, true);
        mRlImagesContainer = (RelativeLayout) this.findViewById(R.id.pw_rlImagesContainer);

        mPlayButton = (FloatingActionButton) this.findViewById(R.id.pw_playButton);
        mIvBackground = (RoundRectImageView) this.findViewById(R.id.pw_ivBackground);
        mBigDiffuserImageView = (DiffuserView) this.findViewById(R.id.pw_ivBigDiffuser);
        mMediumDiffuserImageView = (DiffuserView) this.findViewById(R.id.pw_ivMediumDiffuser);
        mSmallDiffuserImageView = (ImageView) this.findViewById(R.id.pw_ivSmallDiffuser);
        mProgressLineView = (ProgressLineView) this.findViewById(R.id.pw_vProgressLine);

        mIvShuffle = (ImageView) this.findViewById(R.id.pw_ivShuffle);
        mIvSkipPrevious = (ImageView) this.findViewById(R.id.pw_ivSkipPrevious);
        mIvSkipNext = (ImageView) this.findViewById(R.id.pw_ivSkipNext);
        mIvRepeat = (ImageView) this.findViewById(R.id.pw_ivRepeat);

        initListeners();

        if (!isInEditMode()) {
            mProgressLineView.setAlpha(0.0f);
        }
        TypedArray typedArrayValues = context.obtainStyledAttributes(attrs, R.styleable.PlayWidget);

        mBigDiffuserShadowWidth = typedArrayValues.getDimensionPixelSize(R.styleable.PlayWidget_pw_big_diffuser_shadow_width, context.getResources().getDimensionPixelSize(R.dimen.pw_big_diffuser_shadow_width));
        mMediumDiffuserShadowWidth = typedArrayValues.getDimensionPixelSize(R.styleable.PlayWidget_pw_medium_diffuser_shadow_width, context.getResources().getDimensionPixelSize(R.dimen.pw_medium_diffuser_shadow_width));
        mSmallDiffuserShadowWidth = typedArrayValues.getDimensionPixelSize(R.styleable.PlayWidget_pw_small_diffuser_shadow_width, context.getResources().getDimensionPixelSize(R.dimen.pw_small_diffuser_shadow_width));

        mButtonsSize = typedArrayValues.getDimensionPixelSize(R.styleable.PlayWidget_pw_buttons_size, context.getResources().getDimensionPixelSize(R.dimen.pw_image_item_size));

        mBigDiffuserImageView.setShadowSize(mBigDiffuserShadowWidth);
        mMediumDiffuserImageView.setShadowSize(mMediumDiffuserShadowWidth);

        mProgressLineView.setEnabled(typedArrayValues.getBoolean(R.styleable.PlayWidget_pw_progress_line_enabled, true));

        mDiffusersPadding = typedArrayValues.getDimensionPixelSize(R.styleable.PlayWidget_pw_diffusers_padding, context.getResources().getDimensionPixelSize(R.dimen.pw_default_diffusers_padding));

        mProgressLineView.setPadding(typedArrayValues.getDimensionPixelSize(R.styleable.PlayWidget_pw_progress_line_padding, context.getResources().getDimensionPixelSize(R.dimen.pw_default_progress_line_padding)));

        int progressCompleteLineStrokeWidth = typedArrayValues.getDimensionPixelSize(R.styleable.PlayWidget_pw_progress_complete_line_stroke_width, context.getResources().getDimensionPixelSize(R.dimen.pw_progress_complete_line_stroke_width));
        int progressLineStrokeWidth = typedArrayValues.getDimensionPixelSize(R.styleable.PlayWidget_pw_progress_line_stroke_width, context.getResources().getDimensionPixelSize(R.dimen.pw_progress_line_stroke_width));
        int progressBallRadius = typedArrayValues.getDimensionPixelSize(R.styleable.PlayWidget_pw_progress_ball_radius, context.getResources().getDimensionPixelSize(R.dimen.pw_progress_ball_radius));

        if (progressBallRadius * 2.0f < progressCompleteLineStrokeWidth
                || progressBallRadius * 2.0f < progressLineStrokeWidth) {
            throw new IllegalStateException("Progress ball radius cannot be less then complete line stroke or line stroke");
        }
        mProgressLineView.setProgressCompleteLineStrokeWidth(progressCompleteLineStrokeWidth);
        mProgressLineView.setProgressBallRadius(progressBallRadius);
        mProgressLineView.setProgressLineStrokeWidth(progressLineStrokeWidth);

        Drawable d = typedArrayValues.getDrawable(R.styleable.PlayWidget_pw_image_src);
        if (d != null) {
            setImageDrawable(d);
        }

        int bigDiffuserColor = typedArrayValues.getColor(R.styleable.PlayWidget_pw_big_diffuser_color, ContextCompat.getColor(getContext(), R.color.pw_circle_color));
        int mediumDiffuserColor = typedArrayValues.getColor(R.styleable.PlayWidget_pw_medium_diffuser_color, ContextCompat.getColor(getContext(), R.color.pw_circle_color_translucent));

        setProgressLineColor(typedArrayValues.getColor(R.styleable.PlayWidget_pw_progress_line_color, ContextCompat.getColor(getContext(), R.color.pw_progress_line_color)));
        setProgressCompleteColor(typedArrayValues.getColor(R.styleable.PlayWidget_pw_progress_complete_line_color, ContextCompat.getColor(getContext(), R.color.pw_progress_complete_color)));
        setProgressBallColor(typedArrayValues.getColor(R.styleable.PlayWidget_pw_progress_ball_color, ContextCompat.getColor(getContext(), R.color.pw_progress_ball_color)));

        ColorStateList lFabBackgroundTint = typedArrayValues.getColorStateList(R.styleable.PlayWidget_pw_play_button_background_tint);
        if (lFabBackgroundTint != null)
            mPlayButton.setBackgroundTintList(lFabBackgroundTint);

        typedArrayValues.recycle();

        mSmallDiffuserFullSize = context.getResources().getDimensionPixelSize(R.dimen.pw_small_diffuser_size) + mSmallDiffuserShadowWidth * 2;

        //big diffuser
        mIvBackground.setColor(bigDiffuserColor);
        mBigShadowDrawable = new ShadowDrawable(getContext(), true);
        mBigShadowDrawable.hideShadow(false);
        setupDiffuserView(mBigDiffuserImageView, mBigShadowDrawable);

        //medium diffuser
        mMediumDiffuserImageView.setColor(mediumDiffuserColor);
        mMediumDiffuserImageView.setMustDrawRevealAnimation(true);
        mMediumShadowDrawable = new ShadowDrawable(getContext());
        setupDiffuserView(mMediumDiffuserImageView, mMediumShadowDrawable);
        mMediumDiffuserImageView.setScaleX(0.0f);
        mMediumDiffuserImageView.setScaleY(0.0f);

        //small diffuser
        mSmallShadowDrawable = new ShadowDrawable(getContext());
        mSmallShadowDrawable.setup(mSmallDiffuserFullSize / 2.0f, mSmallDiffuserShadowWidth);
        setupDiffuserView(mSmallDiffuserImageView, mSmallShadowDrawable);
        mSmallShadowDrawable.hideShadow(false);
    }
 
Example 19
Source File: FabSpeedDial.java    From fab-speed-dial with Apache License 2.0 4 votes vote down vote up
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);

        if (miniFabTitleTextColorArray != null) {
            titleView.setTextColor(ContextCompat.getColorStateList(getContext(),
                    miniFabTitleTextColorArray[menuItem.getOrder()]));
        }
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);

    if (miniFabBackgroundTintArray != null) {
        miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(),
                miniFabBackgroundTintArray[menuItem.getOrder()]));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}
 
Example 20
Source File: FragmentMap.java    From iGap-Android with GNU Affero General Public License v3.0 2 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle saveInctanceState) {
    super.onViewCreated(view, saveInctanceState);


    /* *//**//* itemIcon = (MaterialDesignTextView) view.findViewById(R.id.mf_icon);*/


    rvIcon = (RelativeLayout) view.findViewById(R.id.rv_icon);

    Drawable mDrawableSkip = ContextCompat.getDrawable(getContext(), R.drawable.ic_circle_shape);
    if (mDrawableSkip != null) {
        mDrawableSkip.setColorFilter(new PorterDuffColorFilter(Color.parseColor(G.appBarColor), PorterDuff.Mode.SRC_IN));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            rvIcon.setBackground(mDrawableSkip);
        }
    }


    imgProfile = (ImageView) view.findViewById(R.id.mf_imgProfile);

    rvSendPosition = (RelativeLayout) view.findViewById(R.id.mf_rv_send_position);
    rvSeePosition = (RelativeLayout) view.findViewById(R.id.mf_rv_see_position);

    rvSendPosition.setEnabled(false);

    accuracy = (TextView) view.findViewById(R.id.mf_txt_accuracy);
    accuracy.setText(getResources().getString(R.string.get_location_data));


    txtTitle = (TextView) view.findViewById(R.id.mf_txt_message);

    txtUserName = (TextView) view.findViewById(R.id.mf_txt_userName);
    txtDistance = (TextView) view.findViewById(R.id.mf_txt_distance);

    txtDistance.setText(getResources().getString(R.string.calculation));

    txtUserName.setTextColor(Color.parseColor(G.appBarColor));

    accuracy.setTextColor(Color.parseColor(G.appBarColor));
    txtDistance.setTextColor(Color.parseColor(G.appBarColor));


    //rvSendPosition.setBackgroundColor(Color.parseColor(G.appBarColor));
    txtTitle.setTextColor(Color.parseColor(G.appBarColor));

    fabOpenMap = (FloatingActionButton) view.findViewById(R.id.mf_fab_openMap);
    fabOpenMap.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(G.fabBottom)));
    fabOpenMap.setColorFilter(Color.WHITE);

    bundle = getArguments();

    if (bundle != null) {

        latitude = bundle.getDouble(FragmentMap.Latitude);
        longitude = bundle.getDouble(FragmentMap.Longitude);

        mode = (Mode) bundle.getSerializable(PosoitionMode);
        if (G.onHelperSetAction != null) {
            G.onHelperSetAction.onAction(ProtoGlobal.ClientAction.SENDING_LOCATION);
        }

        initComponent(view, bundle.getInt("type", 0), bundle.getLong("roomId", 00), bundle.getString("senderId", null));
    } else {
        close();
    }
}