Java Code Examples for com.kabouzeid.appthemehelper.util.ColorUtil#isColorLight()

The following examples show how to use com.kabouzeid.appthemehelper.util.ColorUtil#isColorLight() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: PhonographColorUtil.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
@ColorInt
public static int shiftBackgroundColorForDarkText(@ColorInt int backgroundColor) {
    while (!ColorUtil.isColorLight(backgroundColor)) {
        backgroundColor = ColorUtil.lightenColor(backgroundColor);
    }
    return backgroundColor;
}
 
Example 8
Source File: PhonographColorUtil.java    From Phonograph 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 9
Source File: CardPlayerFragment.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
    Animator backgroundAnimator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //noinspection ConstantConditions
        int x = (int) (fragment.playbackControlsFragment.playPauseFab.getX() + fragment.playbackControlsFragment.playPauseFab.getWidth() / 2 + fragment.playbackControlsFragment.getView().getX());
        int y = (int) (fragment.playbackControlsFragment.playPauseFab.getY() + fragment.playbackControlsFragment.playPauseFab.getHeight() / 2 + fragment.playbackControlsFragment.getView().getY() + fragment.playbackControlsFragment.progressSlider.getHeight());
        float startRadius = Math.max(fragment.playbackControlsFragment.playPauseFab.getWidth() / 2, fragment.playbackControlsFragment.playPauseFab.getHeight() / 2);
        float endRadius = Math.max(fragment.colorBackground.getWidth(), fragment.colorBackground.getHeight());
        fragment.colorBackground.setBackgroundColor(newColor);
        backgroundAnimator = ViewAnimationUtils.createCircularReveal(fragment.colorBackground, x, y, startRadius, endRadius);
    } else {
        backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.colorBackground, fragment.lastColor, newColor);
    }

    AnimatorSet animatorSet = new AnimatorSet();

    animatorSet.play(backgroundAnimator);

    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 10
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 11
Source File: CardPlayerFragment.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
    Animator backgroundAnimator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //noinspection ConstantConditions
        int x = (int) (fragment.playbackControlsFragment.playPauseFab.getX() + fragment.playbackControlsFragment.playPauseFab.getWidth() / 2 + fragment.playbackControlsFragment.getView().getX());
        int y = (int) (fragment.playbackControlsFragment.playPauseFab.getY() + fragment.playbackControlsFragment.playPauseFab.getHeight() / 2 + fragment.playbackControlsFragment.getView().getY() + fragment.playbackControlsFragment.progressSlider.getHeight());
        float startRadius = Math.max(fragment.playbackControlsFragment.playPauseFab.getWidth() / 2, fragment.playbackControlsFragment.playPauseFab.getHeight() / 2);
        float endRadius = Math.max(fragment.colorBackground.getWidth(), fragment.colorBackground.getHeight());
        fragment.colorBackground.setBackgroundColor(newColor);
        backgroundAnimator = ViewAnimationUtils.createCircularReveal(fragment.colorBackground, x, y, startRadius, endRadius);
    } else {
        backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.colorBackground, fragment.lastColor, newColor);
    }

    AnimatorSet animatorSet = new AnimatorSet();

    animatorSet.play(backgroundAnimator);

    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 12
Source File: RetroMusicColorUtil.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@ColorInt
public static int shiftBackgroundColorForDarkText(@ColorInt int backgroundColor) {
    while (!ColorUtil.isColorLight(backgroundColor)) {
        backgroundColor = ColorUtil.lightenColor(backgroundColor);
    }
    return backgroundColor;
}
 
Example 13
Source File: RetroMusicColorUtil.java    From RetroMusicPlayer 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 14
Source File: PhonographColorUtil.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
@ColorInt
public static int shiftBackgroundColorForDarkText(@ColorInt int backgroundColor) {
    while (!ColorUtil.isColorLight(backgroundColor)) {
        backgroundColor = ColorUtil.lightenColor(backgroundColor);
    }
    return backgroundColor;
}
 
Example 15
Source File: PhonographColorUtil.java    From Orin 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 16
Source File: CardPlayerFragment.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
    Animator backgroundAnimator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        int topMargin = fragment.getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
        //noinspection ConstantConditions
        int x = (int) (fragment.playbackControlsFragment.playPauseFab.getX() + fragment.playbackControlsFragment.playPauseFab.getWidth() / 2 + fragment.playbackControlsFragment.getView().getX());
        int y = (int) (topMargin + fragment.playbackControlsFragment.playPauseFab.getY() + fragment.playbackControlsFragment.playPauseFab.getHeight() / 2 + fragment.playbackControlsFragment.getView().getY());
        float startRadius = Math.max(fragment.playbackControlsFragment.playPauseFab.getWidth() / 2, fragment.playbackControlsFragment.playPauseFab.getHeight() / 2);
        float endRadius = Math.max(fragment.colorBackground.getWidth(), fragment.colorBackground.getHeight());
        fragment.colorBackground.setBackgroundColor(newColor);
        backgroundAnimator = ViewAnimationUtils.createCircularReveal(fragment.colorBackground, x, y, startRadius, endRadius);
    } else {
        backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.colorBackground, fragment.lastColor, newColor);
    }

    AnimatorSet animatorSet = new AnimatorSet();

    animatorSet.play(backgroundAnimator);

    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 17
Source File: MusicColorUtil.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
@ColorInt
public static int shiftBackgroundColorForDarkText(@ColorInt int backgroundColor) {
    while (!ColorUtil.isColorLight(backgroundColor)) {
        backgroundColor = ColorUtil.lightenColor(backgroundColor);
    }
    return backgroundColor;
}
 
Example 18
Source File: MusicColorUtil.java    From Music-Player 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 19
Source File: CardPlayerFragment.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
    Animator backgroundAnimator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //noinspection ConstantConditions
        int x = (int) (fragment.playbackControlsFragment.playPauseFab.getX() + fragment.playbackControlsFragment.playPauseFab.getWidth() / 2 + fragment.playbackControlsFragment.getView().getX());
        int y = (int) (fragment.playbackControlsFragment.playPauseFab.getY() + fragment.playbackControlsFragment.playPauseFab.getHeight() / 2 + fragment.playbackControlsFragment.getView().getY() + fragment.playbackControlsFragment.progressSlider.getHeight());
        float startRadius = Math.max(fragment.playbackControlsFragment.playPauseFab.getWidth() / 2, fragment.playbackControlsFragment.playPauseFab.getHeight() / 2);
        float endRadius = Math.max(fragment.colorBackground.getWidth(), fragment.colorBackground.getHeight());
        fragment.colorBackground.setBackgroundColor(newColor);
        backgroundAnimator = ViewAnimationUtils.createCircularReveal(fragment.colorBackground, x, y, startRadius, endRadius);
    } else {
        backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.colorBackground, fragment.lastColor, newColor);
    }

    AnimatorSet animatorSet = new AnimatorSet();

    animatorSet.play(backgroundAnimator);

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