com.kabouzeid.appthemehelper.util.ATHUtil Java Examples

The following examples show how to use com.kabouzeid.appthemehelper.util.ATHUtil. 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: CardPlayerFragment.java    From Phonograph with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    impl.init();

    setUpPlayerToolbar();
    setUpSubFragments();

    setUpRecyclerView();

    slidingUpPanelLayout.addPanelSlideListener(this);
    slidingUpPanelLayout.setAntiDragView(view.findViewById(R.id.draggable_area));

    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            impl.setUpPanelAndAlbumCoverHeight();
        }
    });

    // for some reason the xml attribute doesn't get applied here.
    playingQueueCard.setCardBackgroundColor(ATHUtil.resolveColor(getActivity(), R.attr.cardBackgroundColor));
}
 
Example #2
Source File: SongFileAdapter.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("ConstantConditions")
protected void loadFileImage(File file, final ViewHolder holder) {
    final int iconColor = ATHUtil.resolveColor(activity, R.attr.iconColor);
    if (file.isDirectory()) {
        holder.image.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
        holder.image.setImageResource(R.drawable.ic_folder_white_24dp);
    } else {
        Drawable error = Util.getTintedVectorDrawable(activity, R.drawable.ic_file_music_white_24dp, iconColor);
        Glide.with(activity)
                .load(new AudioFileCover(file.getPath()))
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .error(error)
                .placeholder(error)
                .animate(android.R.anim.fade_in)
                .signature(new MediaStoreSignature("", file.lastModified(), 0))
                .into(holder.image);
    }
}
 
Example #3
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 #4
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 #5
Source File: CardPlayerFragment.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    impl.init();

    setUpPlayerToolbar();
    setUpSubFragments();

    setUpRecyclerView();

    slidingUpPanelLayout.addPanelSlideListener(this);
    slidingUpPanelLayout.setAntiDragView(view.findViewById(R.id.draggable_area));

    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            impl.setUpPanelAndAlbumCoverHeight();
        }
    });

    // for some reason the xml attribute doesn't get applied here.
    playingQueueCard.setCardBackgroundColor(ATHUtil.resolveColor(getActivity(), R.attr.cardBackgroundColor));
}
 
Example #6
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 #7
Source File: SongFileAdapter.java    From VinylMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("ConstantConditions")
protected void loadFileImage(File file, final ViewHolder holder) {
    final int iconColor = ATHUtil.resolveColor(activity, R.attr.iconColor);
    if (file.isDirectory()) {
        holder.image.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
        holder.image.setImageResource(R.drawable.ic_folder_white_24dp);
    } else {
        Drawable error = ImageUtil.getTintedVectorDrawable(activity, R.drawable.ic_file_music_white_24dp, iconColor);
        GlideApp.with(activity)
                .load(new AudioFileCover(file.getPath()))
                .transition(GenericTransitionOptions.with(android.R.anim.fade_in))
                .apply(new RequestOptions()
                        .diskCacheStrategy(DiskCacheStrategy.NONE)
                        .error(error)
                        .placeholder(error)
                        .signature(new MediaStoreSignature("", file.lastModified(), 0)))
                .into(holder.image);
    }
}
 
Example #8
Source File: SongFileAdapter.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("ConstantConditions")
protected void loadFileImage(File file, final ViewHolder holder) {
    final int iconColor = ATHUtil.resolveColor(activity, R.attr.iconColor);
    if (file.isDirectory()) {
        holder.image.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
        holder.image.setImageResource(R.drawable.ic_folder_white_24dp);
    } else {
        Drawable error = Util.getTintedVectorDrawable(activity, R.drawable.ic_file_music_white_24dp, iconColor);
        Glide.with(activity)
                .load(new AudioFileCover(file.getPath()))
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .error(error)
                .placeholder(error)
                .animate(android.R.anim.fade_in)
                .signature(new MediaStoreSignature("", file.lastModified(), 0))
                .into(holder.image);
    }
}
 
Example #9
Source File: AlbumTagEditorActivity.java    From VinylMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void loadImageFromFile(@NonNull final Uri selectedFileUri) {
    GlideApp.with(AlbumTagEditorActivity.this)
            .as(BitmapPaletteWrapper.class)
            .load(selectedFileUri)
            .transition(new GenericTransitionOptions<BitmapPaletteWrapper>().transition(android.R.anim.fade_in))
            .apply(new RequestOptions()
                    .diskCacheStrategy(DiskCacheStrategy.NONE)
                    .skipMemoryCache(true))
            .into(new VinylSimpleTarget<BitmapPaletteWrapper>() {
                @Override
                public void onLoadFailed(@Nullable Drawable errorDrawable) {
                    super.onLoadFailed(errorDrawable);
                }

                @Override
                public void onResourceReady(@NonNull BitmapPaletteWrapper resource, Transition<? super BitmapPaletteWrapper> glideAnimation) {
                    VinylMusicPlayerColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT);
                    albumArtBitmap = ImageUtil.resizeBitmap(resource.getBitmap(), 2048);
                    setImageBitmap(albumArtBitmap, VinylMusicPlayerColorUtil.getColor(resource.getPalette(), ATHUtil.resolveColor(AlbumTagEditorActivity.this, R.attr.defaultFooterColor)));
                    deleteAlbumArt = false;
                    dataChanged();
                    setResult(RESULT_OK);
                }
            });
}
 
Example #10
Source File: MiniPlayerFragment.java    From RetroMusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
private void setUpPlayPauseButton() {

        //int accentColor = ThemeStore.accentColor(getContext());
        //int darkenColor = ColorUtil.darkenColor(accentColor);
        //boolean isDark = ColorUtil.isColorLight(darkenColor);

        //int iconColor = MaterialValueHelper.getPrimaryTextColor(getContext(), isDark);
        //miniPlayerTitle.setTextColor(iconColor);
        //icon.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);

        //TintHelper.setTintAuto(miniPlayerPlayPauseButton, iconColor, false);

        miniPlayerPlayPauseDrawable = new PlayPauseDrawable(getActivity());
        miniPlayerPlayPauseButton.setImageDrawable(miniPlayerPlayPauseDrawable);
        miniPlayerPlayPauseButton.setColorFilter(ATHUtil.resolveColor(getActivity(), R.attr.iconColor, ThemeStore.textColorSecondary(getActivity())), PorterDuff.Mode.SRC_IN);
        miniPlayerPlayPauseButton.setOnClickListener(new PlayPauseButtonOnClickHandler());
    }
 
Example #11
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 #12
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 #13
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 #14
Source File: CardPlayerFragment.java    From Music-Player with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    impl.init();

    setUpPlayerToolbar();
    setUpSubFragments();

    setUpRecyclerView();

    slidingUpPanelLayout.addPanelSlideListener(this);
    slidingUpPanelLayout.setAntiDragView(view.findViewById(R.id.draggable_area));

    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            impl.setUpPanelAndAlbumCoverHeight();
        }
    });

    // for some reason the xml attribute doesn't get applied here.
    playingQueueCard.setCardBackgroundColor(ATHUtil.resolveColor(getActivity(), R.attr.cardBackgroundColor));
}
 
Example #15
Source File: SettingsActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getListView().setPadding(0, 0, 0, 0);
    getListView().addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            ((SettingsActivity) getActivity()).addAppbarLayoutElevation(recyclerView.canScrollVertically(RecyclerView.NO_POSITION) ? 8f : 0f);
        }
    });
    getListView().setBackgroundColor(ATHUtil.resolveColor(getActivity(), android.R.attr.colorPrimary));
    invalidateSettings();
    PreferenceUtil.getInstance(getActivity()).registerOnSharedPreferenceChangedListener(this);
}
 
Example #16
Source File: CardPlayerFragment.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        impl.init();

        setUpPlayerToolbar();
        setUpSubFragments();

        setUpRecyclerView(recyclerView,slidingUpPanelLayout);

        slidingUpPanelLayout.addPanelSlideListener(this);
        slidingUpPanelLayout.setAntiDragView(view.findViewById(R.id.draggable_area));

        view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                impl.setUpPanelAndAlbumCoverHeight();
            }
        });

        // for some reason the xml attribute doesn't get applied here.
        playingQueueCard.setCardBackgroundColor(ATHUtil.resolveColor(getActivity(), R.attr.cardBackgroundColor));

        //Allows the list items to draw out of bounds when swiping, but also makes the listview
        //float above everything else. Disabling for now.

//        playingQueueCard.setClipToOutline(false);
//        disableClipOnParents(recyclerView);
    }
 
Example #17
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 #18
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 #19
Source File: MainActivity.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
private void setUpNavigationView() {
    int accentColor = ThemeStore.accentColor(this);
    NavigationViewUtil.setItemIconColors(navigationView, ATHUtil.resolveColor(this, R.attr.iconColor, ThemeStore.textColorSecondary(this)), accentColor);
    NavigationViewUtil.setItemTextColors(navigationView, ThemeStore.textColorPrimary(this), accentColor);

    navigationView.setNavigationItemSelectedListener(menuItem -> {
        drawerLayout.closeDrawers();
        switch (menuItem.getItemId()) {
            case R.id.nav_library:
                new Handler().postDelayed(() -> setMusicChooser(LIBRARY), 200);
                break;
            case R.id.nav_folders:
                new Handler().postDelayed(() -> setMusicChooser(FOLDERS), 200);
                break;
            case R.id.action_scan:
                new Handler().postDelayed(() -> {
                    ScanMediaFolderChooserDialog dialog = ScanMediaFolderChooserDialog.create();
                    dialog.show(getSupportFragmentManager(), "SCAN_MEDIA_FOLDER_CHOOSER");
                }, 200);
                break;
            case R.id.nav_equalizer:
                NavigationUtil.openEqualizer(this);
                break;
            case R.id.nav_settings:
                new Handler().postDelayed(() -> startActivity(new Intent(MainActivity.this, SettingsActivity.class)), 200);
                break;
            case R.id.nav_about:
                new Handler().postDelayed(() -> startActivity(new Intent(MainActivity.this, AboutActivity.class)), 200);
                break;
        }
        return true;
    });
}
 
Example #20
Source File: AlbumTagEditorActivity.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void loadImageFromFile(@NonNull final Uri selectedFileUri) {
    Glide.with(AlbumTagEditorActivity.this)
            .load(selectedFileUri)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(AlbumTagEditorActivity.this), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .into(new SimpleTarget<BitmapPaletteWrapper>() {
                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    e.printStackTrace();
                    Toast.makeText(AlbumTagEditorActivity.this, e.toString(), Toast.LENGTH_LONG).show();
                }

                @Override
                public void onResourceReady(BitmapPaletteWrapper resource, GlideAnimation<? super BitmapPaletteWrapper> glideAnimation) {
                    MusicColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT);
                    albumArtBitmap = ImageUtil.resizeBitmap(resource.getBitmap(), 2048);
                    setImageBitmap(albumArtBitmap, MusicColorUtil.getColor(resource.getPalette(), ATHUtil.resolveColor(AlbumTagEditorActivity.this, R.attr.defaultFooterColor)));
                    deleteAlbumArt = false;
                    dataChanged();
                    setResult(RESULT_OK);
                }
            });
}
 
Example #21
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;
}
 
Example #22
Source File: AbsThemeActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private void changeBackgroundShape() {
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("corner_window", false)) {
        getWindow().setBackgroundDrawableResource(R.drawable.round_window);
    } else {
        getWindow().setBackgroundDrawableResource(R.drawable.square_window);
    }
    View decor = getWindow().getDecorView();
    GradientDrawable gradientDrawable = (GradientDrawable) decor.getBackground();
    gradientDrawable.setColor(ATHUtil.resolveColor(this, android.R.attr.windowBackground));
}
 
Example #23
Source File: PlayerFragment.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("StaticFieldLeak")
private void updateLyrics() {
    if (updateLyricsAsyncTask != null) updateLyricsAsyncTask.cancel(false);
    final Song song = MusicPlayerRemote.getCurrentSong();
    updateLyricsAsyncTask = new AsyncTask<Void, Void, Boolean>() {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            mToolbar.getMenu().removeItem(R.id.action_show_lyrics);
        }

        @Override
        protected Boolean doInBackground(Void... params) {
            return LyricUtil.isLrcFileExist(song.title, song.artistName);

        }

        @Override
        protected void onPostExecute(Boolean l) {
            if (l) {
                Activity activity = getActivity();
                if (mToolbar != null && activity != null)
                    if (mToolbar.getMenu().findItem(R.id.action_show_lyrics) == null) {
                        int color = ATHUtil.resolveColor(activity, R.attr.iconColor, Color.TRANSPARENT);
                        Drawable drawable = Util.getTintedVectorDrawable(activity, R.drawable.ic_comment_text_outline_white_24dp, color);
                        mToolbar.getMenu()
                                .add(Menu.NONE, R.id.action_show_lyrics, Menu.NONE, R.string.action_show_lyrics)
                                .setIcon(drawable)
                                .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
                    }
            } else {
                if (mToolbar != null) {
                    mToolbar.getMenu().removeItem(R.id.action_show_lyrics);
                }
            }

        }
    }.execute();
}
 
Example #24
Source File: AlbumsFragment.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    if (!Util.isTablet(getResources())) {
        ViewUtil.setMargins(recyclerView, 0, 32, 0, 0);
        final int spanCount = loadGridSize(); // no of columns
        int spacing = 4; // 4px

        // Create a custom SpanSizeLookup where the first item spans both columns
        //I wonder why this has to be juxtaposed for it to work
        getLayoutManager().setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                if (true) {
                    return spanCount;
                } else {
                    return 1;
                }
            }
        });

        indexLayoutManager.attach(getRecyclerView(), getActivity());
        optRoundCardView.setCardBackgroundColor(ATHUtil.resolveColor(getActivity(), R.attr.cardBackgroundColor));
    }else {
        GridSpacingItemDecoration gridSpacingItemDecoration = new GridSpacingItemDecoration(loadGridSize(), 4, false);
        getRecyclerView().addItemDecoration(gridSpacingItemDecoration);
    }
}
 
Example #25
Source File: AlbumTagEditorActivity.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void loadImageFromFile(@NonNull final Uri selectedFileUri) {
    Glide.with(AlbumTagEditorActivity.this)
            .load(selectedFileUri)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(AlbumTagEditorActivity.this), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .into(new SimpleTarget<BitmapPaletteWrapper>() {
                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    e.printStackTrace();
                    Toast.makeText(AlbumTagEditorActivity.this, e.toString(), Toast.LENGTH_LONG).show();
                }

                @Override
                public void onResourceReady(BitmapPaletteWrapper resource, GlideAnimation<? super BitmapPaletteWrapper> glideAnimation) {
                    PhonographColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT);
                    albumArtBitmap = ImageUtil.resizeBitmap(resource.getBitmap(), 2048);
                    setImageBitmap(albumArtBitmap, PhonographColorUtil.getColor(resource.getPalette(), ATHUtil.resolveColor(AlbumTagEditorActivity.this, R.attr.defaultFooterColor)));
                    deleteAlbumArt = false;
                    dataChanged();
                    setResult(RESULT_OK);
                }
            });
}
 
Example #26
Source File: MainActivity.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
private void setUpNavigationView() {
    int accentColor = ThemeStore.accentColor(this);
    NavigationViewUtil.setItemIconColors(navigationView, ATHUtil.resolveColor(this, R.attr.iconColor, ThemeStore.textColorSecondary(this)), accentColor);
    NavigationViewUtil.setItemTextColors(navigationView, ThemeStore.textColorPrimary(this), accentColor);

    checkSetUpPro();
    navigationView.setNavigationItemSelectedListener(menuItem -> {
        drawerLayout.closeDrawers();
        switch (menuItem.getItemId()) {
            case R.id.nav_library:
                new Handler().postDelayed(() -> setMusicChooser(LIBRARY), 200);
                break;
            case R.id.nav_folders:
                new Handler().postDelayed(() -> setMusicChooser(FOLDERS), 200);
                break;
            case R.id.buy_pro:
                new Handler().postDelayed(() -> startActivity(new Intent(MainActivity.this, PurchaseActivity.class)), 200);
                break;
            case R.id.action_scan:
                new Handler().postDelayed(() -> {
                    ScanMediaFolderChooserDialog dialog = ScanMediaFolderChooserDialog.create();
                    dialog.show(getSupportFragmentManager(), "SCAN_MEDIA_FOLDER_CHOOSER");
                }, 200);
                break;
            case R.id.nav_settings:
                new Handler().postDelayed(() -> startActivity(new Intent(MainActivity.this, SettingsActivity.class)), 200);
                break;
            case R.id.nav_about:
                new Handler().postDelayed(() -> startActivity(new Intent(MainActivity.this, AboutActivity.class)), 200);
                break;
        }
        return true;
    });
}
 
Example #27
Source File: PlayingQueueAdapter.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public static int getBackgroundColor(AppCompatActivity activity){
    //TODO: Find a better way to get the album background color
    TextView tV = activity.findViewById(R.id.player_queue_sub_header);
    if(tV != null){
        return tV.getCurrentTextColor();
    } else {
        return ATHUtil.resolveColor(activity, R.attr.cardBackgroundColor);
    }
}
 
Example #28
Source File: AlbumTagEditorActivity.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void loadImageFromFile(@NonNull final Uri selectedFileUri) {
    Glide.with(AlbumTagEditorActivity.this)
            .load(selectedFileUri)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(AlbumTagEditorActivity.this), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .into(new SimpleTarget<BitmapPaletteWrapper>() {
                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    e.printStackTrace();
                    Toast.makeText(AlbumTagEditorActivity.this, e.toString(), Toast.LENGTH_LONG).show();
                }

                @Override
                public void onResourceReady(BitmapPaletteWrapper resource, GlideAnimation<? super BitmapPaletteWrapper> glideAnimation) {
                    PhonographColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT);
                    albumArtBitmap = getResizedAlbumCover(resource.getBitmap(), 2048);
                    setImageBitmap(albumArtBitmap, PhonographColorUtil.getColor(resource.getPalette(), ATHUtil.resolveColor(AlbumTagEditorActivity.this, R.attr.defaultFooterColor)));
                    deleteAlbumArt = false;
                    dataChanged();
                    setResult(RESULT_OK);
                }
            });
}
 
Example #29
Source File: FlatPlayerFragment.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private void setUpPlayerToolbar() {
    mToolbar.inflateMenu(R.menu.menu_player);
    mToolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());
    mToolbar.setOnMenuItemClickListener(this);

    iconColor = PreferenceUtil.getInstance(getContext()).getAdaptiveColor() ?
            Color.WHITE :
            ATHUtil.resolveColor(getContext(), R.attr.iconColor);
}
 
Example #30
Source File: HomeFragment.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private void setupToolbar() {
    mAppbar.addOnOffsetChangedListener(new AppBarStateChangeListener() {
        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state) {
            int color;
            switch (state) {
                case COLLAPSED:
                    color = ATHUtil.resolveColor(getContext(), R.attr.iconColor);
                    break;
                default:
                case EXPANDED:
                case IDLE:
                    color = ContextCompat.getColor(getContext(), R.color.md_white_1000);
                    break;
            }
            mToolbarLayout.setExpandedTitleColor(color);
            ToolbarColorizeHelper.colorizeToolbar(mToolbar, color, getActivity());
        }

    });
    mToolbar.setTitle(R.string.home);
    mToolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
    getActivity().setTitle(R.string.app_name);
    getMainActivity().setSupportActionBar(mToolbar);

    mTitle.setText(getTimeOfTheDay());
}