com.kabouzeid.appthemehelper.util.ColorUtil Java Examples

The following examples show how to use com.kabouzeid.appthemehelper.util.ColorUtil. 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: ArtistDetailActivity.java    From Music-Player with GNU General Public License v3.0 6 votes vote down vote up
private void setColors(int color) {
    toolbarColor = color;
    headerView.setBackgroundColor(color);

    setNavigationbarColor(color);
    setTaskDescriptionColor(color);

    toolbar.setBackgroundColor(color);
    setSupportActionBar(toolbar); // needed to auto readjust the toolbar content color
    setStatusbarColor(color);

    int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
    durationIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    songCountIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    albumCountIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    durationTextView.setTextColor(secondaryTextColor);
    songCountTextView.setTextColor(secondaryTextColor);
    albumCountTextView.setTextColor(secondaryTextColor);
}
 
Example #2
Source File: AlbumDetailActivity.java    From Phonograph with GNU General Public License v3.0 6 votes vote down vote up
private void setColors(int color) {
    toolbarColor = color;
    headerView.setBackgroundColor(color);

    setNavigationbarColor(color);
    setTaskDescriptionColor(color);

    toolbar.setBackgroundColor(color);
    setSupportActionBar(toolbar); // needed to auto readjust the toolbar content color
    setStatusbarColor(color);

    int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
    artistIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    durationIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    songCountIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    albumYearIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    artistTextView.setTextColor(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(color)));
    durationTextView.setTextColor(secondaryTextColor);
    songCountTextView.setTextColor(secondaryTextColor);
    albumYearTextView.setTextColor(secondaryTextColor);
}
 
Example #3
Source File: ArtistDetailActivity.java    From Phonograph with GNU General Public License v3.0 6 votes vote down vote up
private void setColors(int color) {
    toolbarColor = color;
    headerView.setBackgroundColor(color);

    setNavigationbarColor(color);
    setTaskDescriptionColor(color);

    toolbar.setBackgroundColor(color);
    setSupportActionBar(toolbar); // needed to auto readjust the toolbar content color
    setStatusbarColor(color);

    int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
    durationIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    songCountIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    albumCountIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    durationTextView.setTextColor(secondaryTextColor);
    songCountTextView.setTextColor(secondaryTextColor);
    albumCountTextView.setTextColor(secondaryTextColor);
}
 
Example #4
Source File: FlatPlayerFragment.java    From VinylMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
    Animator backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.playbackControlsFragment.getView(), fragment.lastColor, newColor);
    Animator statusBarAnimator = ViewUtil.createBackgroundColorTransition(fragment.playerStatusBar, fragment.lastColor, newColor);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(backgroundAnimator, statusBarAnimator);

    if (!ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
        int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor;
        int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor;
        Animator subHeaderAnimator = ViewUtil.createTextColorTransition(fragment.playerQueueSubHeader, adjustedLastColor, adjustedNewColor);
        animatorSet.play(subHeaderAnimator);
    }

    animatorSet.setDuration(ViewUtil.VINYL_MUSIC_PLAYER_ANIM_TIME);
    return animatorSet;
}
 
Example #5
Source File: CardPlayerPlaybackControlsFragment.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
private void setUpPlayPauseFab() {
    final int fabColor = Color.WHITE;
    TintHelper.setTintAuto(playPauseFab, fabColor, true);

    playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity());

    playPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called
    playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
    playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler());
    playPauseFab.post(new Runnable() {
        @Override
        public void run() {
            if (playPauseFab != null) {
                playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
                playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
            }
        }
    });
}
 
Example #6
Source File: AbsThemeActivity.java    From Phonograph with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This will set the color of the view with the id "status_bar" on KitKat and Lollipop.
 * On Lollipop if no such view is found it will set the statusbar color using the native method.
 *
 * @param color the new statusbar color (will be shifted down on Lollipop and above)
 */
public void setStatusbarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        final View statusBar = getWindow().getDecorView().getRootView().findViewById(R.id.status_bar);
        if (statusBar != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                statusBar.setBackgroundColor(ColorUtil.darkenColor(color));
                setLightStatusbarAuto(color);
            } else {
                statusBar.setBackgroundColor(color);
            }
        } else if (Build.VERSION.SDK_INT >= 21) {
            getWindow().setStatusBarColor(ColorUtil.darkenColor(color));
            setLightStatusbarAuto(color);
        }
    }
}
 
Example #7
Source File: CardPlayerPlaybackControlsFragment.java    From Phonograph with GNU General Public License v3.0 6 votes vote down vote up
private void setUpPlayPauseFab() {
    final int fabColor = Color.WHITE;
    TintHelper.setTintAuto(playPauseFab, fabColor, true);

    playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity());

    playPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called
    playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
    playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler());
    playPauseFab.post(() -> {
        if (playPauseFab != null) {
            playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
            playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
        }
    });
}
 
Example #8
Source File: FlatPlayerFragment.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
    Animator backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.playbackControlsFragment.getView(), fragment.lastColor, newColor);
    Animator statusBarAnimator = ViewUtil.createBackgroundColorTransition(fragment.playerStatusBar, fragment.lastColor, newColor);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(backgroundAnimator, statusBarAnimator);

    if (!ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
        int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor;
        int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor;
        Animator subHeaderAnimator = ViewUtil.createTextColorTransition(fragment.playerQueueSubHeader, adjustedLastColor, adjustedNewColor);
        animatorSet.play(subHeaderAnimator);
    }

    animatorSet.setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME);
    return animatorSet;
}
 
Example #9
Source File: ArtistDetailActivity.java    From VinylMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
private void setColors(int color) {
    toolbarColor = color;
    headerView.setBackgroundColor(color);

    setNavigationbarColor(color);
    setTaskDescriptionColor(color);

    toolbar.setBackgroundColor(color);
    setSupportActionBar(toolbar); // needed to auto readjust the toolbar content color
    setStatusbarColor(color);

    int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
    durationIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    songCountIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    albumCountIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    durationTextView.setTextColor(secondaryTextColor);
    songCountTextView.setTextColor(secondaryTextColor);
    albumCountTextView.setTextColor(secondaryTextColor);
}
 
Example #10
Source File: AbsThemeActivity.java    From VinylMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This will set the color of the view with the id "status_bar" on KitKat and Lollipop.
 * On Lollipop if no such view is found it will set the statusbar color using the native method.
 *
 * @param color the new statusbar color (will be shifted down on Lollipop and above)
 */
public void setStatusbarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        final View statusBar = getWindow().getDecorView().getRootView().findViewById(R.id.status_bar);
        if (statusBar != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                statusBar.setBackgroundColor(ColorUtil.darkenColor(color));
                setLightStatusbarAuto(color);
            } else {
                statusBar.setBackgroundColor(color);
            }
        } else if (Build.VERSION.SDK_INT >= 21) {
            getWindow().setStatusBarColor(ColorUtil.darkenColor(color));
            setLightStatusbarAuto(color);
        }
    }
}
 
Example #11
Source File: AbsThemeActivity.java    From Music-Player with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This will set the color of the view with the id "status_bar" on KitKat and Lollipop.
 * On Lollipop if no such view is found it will set the statusbar color using the native method.
 *
 * @param color the new statusbar color (will be shifted down on Lollipop and above)
 */
public void setStatusbarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        final View statusBar = getWindow().getDecorView().getRootView().findViewById(R.id.status_bar);
        if (statusBar != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                statusBar.setBackgroundColor(ColorUtil.darkenColor(color));
                setLightStatusbarAuto(color);
            } else {
                statusBar.setBackgroundColor(color);
            }
        } else if (Build.VERSION.SDK_INT >= 21) {
            getWindow().setStatusBarColor(ColorUtil.darkenColor(color));
            setLightStatusbarAuto(color);
        }
    }
}
 
Example #12
Source File: CardPlayerPlaybackControlsFragment.java    From Music-Player with GNU General Public License v3.0 6 votes vote down vote up
private void setUpPlayPauseFab() {
    final int fabColor = ThemeStore.accentColor(getActivity());
    TintHelper.setTintAuto(playPauseFab, fabColor, true);

    playerFabPlayPauseDrawable = new PlayPauseDrawable(getActivity());

    playPauseFab.setImageDrawable(playerFabPlayPauseDrawable); // Note: set the drawable AFTER TintHelper.setTintAuto() was called
    playPauseFab.setColorFilter(MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil.isColorLight(fabColor)), PorterDuff.Mode.SRC_IN);
    playPauseFab.setOnClickListener(new PlayPauseButtonOnClickHandler());
    playPauseFab.post(() -> {
        if (playPauseFab != null) {
            playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
            playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
        }
    });
}
 
Example #13
Source File: AlbumDetailActivity.java    From VinylMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
private void setColors(int color) {
    toolbarColor = color;
    headerView.setBackgroundColor(color);

    setNavigationbarColor(color);
    setTaskDescriptionColor(color);

    toolbar.setBackgroundColor(color);
    setSupportActionBar(toolbar); // needed to auto readjust the toolbar content color
    setStatusbarColor(color);

    int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(this, ColorUtil.isColorLight(color));
    artistIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    durationIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    songCountIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    albumYearIconImageView.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_IN);
    artistTextView.setTextColor(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(color)));
    durationTextView.setTextColor(secondaryTextColor);
    songCountTextView.setTextColor(secondaryTextColor);
    albumYearTextView.setTextColor(secondaryTextColor);
}
 
Example #14
Source File: FlatPlayerFragment.java    From Phonograph with GNU General Public License v3.0 6 votes vote down vote up
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
    Animator backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.playbackControlsFragment.getView(), fragment.lastColor, newColor);
    Animator statusBarAnimator = ViewUtil.createBackgroundColorTransition(fragment.playerStatusBar, fragment.lastColor, newColor);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(backgroundAnimator, statusBarAnimator);

    if (!ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
        int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor;
        int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor;
        Animator subHeaderAnimator = ViewUtil.createTextColorTransition(fragment.playerQueueSubHeader, adjustedLastColor, adjustedNewColor);
        animatorSet.play(subHeaderAnimator);
    }

    animatorSet.setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME);
    return animatorSet;
}
 
Example #15
Source File: AlbumDetailActivity.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
    Log.d(TAG, "SONG LIST RV SCROLL 0: " + (scrollY));
    scrollY += albumArtViewHeight + titleViewHeight;
    float flexibleRange = albumArtViewHeight - headerOffset;
    Log.d(TAG, "SONG LIST RV SCROLL 1: " + (scrollY));
    // Translate album cover
    albumArtImageView.setTranslationY(Math.max(-albumArtViewHeight, -scrollY / 2));

    // Translate list background
    songsBackgroundView.setTranslationY(Math.max(0, -scrollY + albumArtViewHeight));

    // Change alpha of overlay
    toolbarAlpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
    toolbar.setBackgroundColor(ColorUtil.withAlpha(toolbarColor, toolbarAlpha));
    songListTitle.setTextColor(ColorUtil.withAlpha(toolbarColor, 1 - toolbarAlpha));
    setStatusbarColor(ColorUtil.withAlpha(toolbarColor, cab != null && cab.isActive() ? 1 : toolbarAlpha));

    // Translate name text
    int maxTitleTranslationY = albumArtViewHeight;
    int titleTranslationY = maxTitleTranslationY - scrollY;
    titleTranslationY = Math.max(headerOffset, titleTranslationY);
    Log.d(TAG, "SONG LIST CONTANIER SCROLL: " + (titleTranslationY));
    scrollContainerCard.setTranslationY(titleTranslationY);
    titleContainer.setTranslationY(titleTranslationY);
}
 
Example #16
Source File: FlatPlayerFragment.java    From Music-Player with GNU General Public License v3.0 6 votes vote down vote up
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
    Animator backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.playbackControlsFragment.getView(), fragment.lastColor, newColor);
    Animator statusBarAnimator = ViewUtil.createBackgroundColorTransition(fragment.playerStatusBar, fragment.lastColor, newColor);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(backgroundAnimator, statusBarAnimator);

    if (!ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
        int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor;
        int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor;
        Animator subHeaderAnimator = ViewUtil.createTextColorTransition(fragment.playerQueueSubHeader, adjustedLastColor, adjustedNewColor);
        animatorSet.play(subHeaderAnimator);
    }

    animatorSet.setDuration(ViewUtil.MUSIC_ANIM_TIME);
    return animatorSet;
}
 
Example #17
Source File: AbsThemeActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This will set the color of the view with the id "status_bar" on KitKat and Lollipop.
 * On Lollipop if no such view is found it will set the statusbar color using the native method.
 *
 * @param color the new statusbar color (will be shifted down on Lollipop and above)
 */
public void setStatusbarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        final View statusBar = getWindow().getDecorView().getRootView().findViewById(R.id.status_bar);
        if (statusBar != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                statusBar.setBackgroundColor(ColorUtil.darkenColor(color));
                setLightStatusbarAuto(color);
            } else {
                statusBar.setBackgroundColor(color);
            }
        } else if (Build.VERSION.SDK_INT >= 21) {
            getWindow().setStatusBarColor(ColorUtil.darkenColor(color));
            setLightStatusbarAuto(color);
        }
    }
}
 
Example #18
Source File: PlayerPlaybackControlsFragment.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setDark(int dark) {
    int color = ATHUtil.resolveColor(getActivity(), android.R.attr.colorBackground);
    if (ColorUtil.isColorLight(color)) {
        lastPlaybackControlsColor = MaterialValueHelper
                .getSecondaryTextColor(getActivity(), true);
        lastDisabledPlaybackControlsColor = MaterialValueHelper
                .getSecondaryDisabledTextColor(getActivity(), true);
    } else {
        lastPlaybackControlsColor = MaterialValueHelper
                .getPrimaryTextColor(getActivity(), false);
        lastDisabledPlaybackControlsColor = MaterialValueHelper
                .getPrimaryDisabledTextColor(getActivity(), false);
    }

    if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) {
        TintHelper.setTintAuto(playPauseFab, dark, true);
        setProgressBarColor(progressSlider, dark);
        text.setTextColor(dark);
    } else {
        text.setTextColor(ThemeStore.accentColor(getContext()));
    }
    updateRepeatState();
    updateShuffleState();
    updatePrevNextColor();
}
 
Example #19
Source File: FlatPlaybackControlsFragment.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
public void setDark(int dark) {
    int color = ATHUtil.resolveColor(getActivity(), android.R.attr.colorBackground);
    if (ColorUtil.isColorLight(color)) {
        lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(getActivity(), true);
        lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(getActivity(), true);
    } else {
        lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(getActivity(), false);
        lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(getActivity(), false);
    }

    if (PreferenceUtil.getInstance(getContext()).getAdaptiveColor()) {
        updateTextColors(dark);
        setProgressBarColor(dark);
        TintHelper.setTintAuto(mPlayerPlayPauseFab, dark, true);
    } else {
        int accentColor = ThemeStore.accentColor(getContext());
        updateTextColors(accentColor);
        setProgressBarColor(accentColor);
    }

    updateRepeatState();
    updateShuffleState();
    updatePrevNextColor();
    updateProgressTextColor();
}
 
Example #20
Source File: SongAdapter.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
private void setColors(int color, ViewHolder holder) {
    if (holder.paletteColorContainer != null) {
        holder.paletteColorContainer.setBackgroundColor(color);
        if (holder.title != null) {
            holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
        if (holder.text != null) {
            holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
    }
}
 
Example #21
Source File: VinylMusicPlayerColorUtil.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@ColorInt
public static int shiftBackgroundColorForLightText(@ColorInt int backgroundColor) {
    while (ColorUtil.isColorLight(backgroundColor)) {
        backgroundColor = ColorUtil.darkenColor(backgroundColor);
    }
    return backgroundColor;
}
 
Example #22
Source File: AlbumDetailActivity.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
    scrollY += headerViewHeight;

    // Change alpha of overlay
    float headerAlpha = Math.max(0, Math.min(1, (float) 2 * scrollY / headerViewHeight));
    headerOverlay.setBackgroundColor(ColorUtil.withAlpha(toolbarColor, headerAlpha));

    // Translate name text
    headerView.setTranslationY(Math.max(-scrollY, -headerViewHeight));
    headerOverlay.setTranslationY(Math.max(-scrollY, -headerViewHeight));
    albumArtImageView.setTranslationY(Math.max(-scrollY, -headerViewHeight));
}
 
Example #23
Source File: ArtistAdapter.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private void setColors(int color, ViewHolder holder) {
    if (holder.paletteColorContainer != null) {
        holder.paletteColorContainer.setBackgroundColor(color);
        if (holder.title != null) {
            holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
        if (holder.text != null) {
            holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
    }
}
 
Example #24
Source File: HorizontalAlbumAdapter.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void setColors(int color, ViewHolder holder) {
    if (holder.itemView != null) {
        //CardView card = (CardView) holder.itemView;
        //card.setCardBackgroundColor(color);
        if (holder.title != null) {
            holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
        if (holder.text != null) {
            holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
    }
}
 
Example #25
Source File: HomeAdapter.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int i) {
    ViewHolder viewholder = (ViewHolder) holder;
    Playlist playlist = dataSet.get(holder.getAdapterPosition());
    if (viewholder.title != null) {
        viewholder.title.setVisibility(View.VISIBLE);
        viewholder.title.setText(playlist.name);
    }

    int aColor = ThemeStore.accentColor(activity);
    viewholder.dash.setBackgroundColor(aColor);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        viewholder.seeAll.setBackgroundTintList(ColorStateList.valueOf(aColor));
    } else {
        viewholder.seeAll.setBackgroundColor(aColor);
    }
    int color = MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(aColor));
    viewholder.seeAll.setTextColor(color);
    viewholder.seeAll.setOnClickListener(v -> {
        NavigationUtil.goToPlaylistNew(activity, playlist);
    });

    if (viewholder.recyclerView != null) {
        viewholder.recyclerView.setHasFixedSize(true);
        viewholder.recyclerView.setLayoutManager(new LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false));
        viewholder.recyclerView.setItemAnimator(new DefaultItemAnimator());
        PlaylistSongsLoader.getPlaylistSongList(activity, playlist)
                .subscribeOn(Schedulers.computation())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(songs -> viewholder.recyclerView.setAdapter(new HorizontalItemAdapter(activity, songs)));
    }


}
 
Example #26
Source File: LockScreenActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private void changeColor(int color) {
    Drawable drawable = ContextCompat.getDrawable(LockScreenActivity.this, R.drawable.shape_rounded_edit);
    if (drawable != null) {
        drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
        mSwipeButton.setBackground(drawable);
    }

    int colorPrimary = MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(color));
    mSwipeButton.setCenterTextColor(colorPrimary);
}
 
Example #27
Source File: AbsSlidingMusicPanelActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public void onPanelExpanded(View panel) {
    // setting fragments values
    int playerFragmentColor = mPlayerFragment.getPaletteColor();
    if (PreferenceUtil.getInstance(this).getAdaptiveColor() || ATHUtil.isWindowBackgroundDark(this)
            /*|| (currentNowPlayingScreen == NowPlayingScreen.FULL)*/) {
        super.setLightStatusbar(false);
    } else
        super.setLightStatusbar(true);
    super.setTaskDescriptionColor(playerFragmentColor);
    super.setNavigationbarColor(ColorUtil.darkenColor(ThemeStore.primaryColor(this)));

    mPlayerFragment.setMenuVisibility(true);
    mPlayerFragment.setUserVisibleHint(true);
    mPlayerFragment.onShow();
}
 
Example #28
Source File: AbsSlidingMusicPanelActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public void onPanelCollapsed(View panel) {
    // restore values
    super.setLightStatusbar(mLightStatusbar);
    super.setTaskDescriptionColor(mTaskColor);
    //setNavigationbarColor(ColorUtil.darkenColor(ThemeStore.primaryColor(this)));
    setNavigationbarColor(ColorUtil.darkenColor(ThemeStore.primaryColor(this)));
    //super.setNavigationbarColor(mNavigationbarColor);

    mPlayerFragment.setMenuVisibility(false);
    mPlayerFragment.setUserVisibleHint(false);
    mPlayerFragment.onHide();

}
 
Example #29
Source File: AbsTagEditorActivity.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
    float alpha;
    if (!isInNoImageMode) {
        alpha = 1 - (float) Math.max(0, headerVariableSpace - scrollY) / headerVariableSpace;
    } else {
        header.setTranslationY(scrollY);
        alpha = 1;
    }
    toolbar.setBackgroundColor(ColorUtil.withAlpha(paletteColorPrimary, alpha));
    image.setTranslationY(scrollY / 2);
}
 
Example #30
Source File: AbsMainActivityFragment.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public void setStatusbarColor(View view, int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        final View statusBar = view.findViewById(R.id.status_bar);
        if (statusBar != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getMainActivity().setLightStatusbarAuto(color);
                statusBar.setBackgroundColor(ColorUtil.darkenColor(color));
            } else {
                statusBar.setBackgroundColor(color);
            }
        }
    }
}