Added song track info

This commit is contained in:
h4h13 2020-01-06 08:42:32 +05:30
parent 9b89259178
commit 813fb86073
55 changed files with 2267 additions and 1528 deletions

View file

@ -16,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.App import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
@ -268,6 +269,12 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
menuInflater.inflate(R.menu.menu_album_detail, menu) menuInflater.inflate(R.menu.menu_album_detail, menu)
val sortOrder = menu.findItem(R.id.action_sort_order) val sortOrder = menu.findItem(R.id.action_sort_order)
setUpSortOrderMenu(sortOrder.subMenu) setUpSortOrderMenu(sortOrder.subMenu)
ToolbarContentTintHelper.handleOnCreateOptionsMenu(
this,
toolbar,
menu,
getToolbarBackgroundColor(toolbar)
)
return super.onCreateOptionsMenu(menu) return super.onCreateOptionsMenu(menu)
} }

View file

@ -8,9 +8,11 @@ import android.content.SharedPreferences
import android.os.Bundle import android.os.Bundle
import android.provider.MediaStore import android.provider.MediaStore
import android.util.Log import android.util.Log
import android.view.Menu
import android.view.View import android.view.View
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
@ -249,6 +251,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
} }
} }
companion object { companion object {
const val APP_INTRO_REQUEST = 2323 const val APP_INTRO_REQUEST = 2323
const val HOME = 0 const val HOME = 0

View file

@ -1,11 +1,19 @@
package code.name.monkey.retromusic.fragments.base package code.name.monkey.retromusic.fragments.base
import android.content.Context import android.content.Context
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.webkit.MimeTypeMap
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.interfaces.MusicServiceEventListener import code.name.monkey.retromusic.interfaces.MusicServiceEventListener
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.RetroUtil
import org.jaudiotagger.audio.AudioFileIO
import java.io.File
import java.net.URLEncoder
import java.util.Locale
/** /**
* Created by hemanths on 18/08/17. * Created by hemanths on 18/08/17.
@ -33,7 +41,6 @@ open class AbsMusicServiceFragment : Fragment(), MusicServiceEventListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
playerActivity?.addMusicServiceEventListener(this) playerActivity?.addMusicServiceEventListener(this)
} }
override fun onDestroyView() { override fun onDestroyView() {
@ -42,34 +49,50 @@ open class AbsMusicServiceFragment : Fragment(), MusicServiceEventListener {
} }
override fun onPlayingMetaChanged() { override fun onPlayingMetaChanged() {
} }
override fun onServiceConnected() { override fun onServiceConnected() {
} }
override fun onServiceDisconnected() { override fun onServiceDisconnected() {
} }
override fun onQueueChanged() { override fun onQueueChanged() {
} }
override fun onPlayStateChanged() { override fun onPlayStateChanged() {
} }
override fun onRepeatModeChanged() { override fun onRepeatModeChanged() {
} }
override fun onShuffleModeChanged() { override fun onShuffleModeChanged() {
} }
override fun onMediaStoreChanged() { override fun onMediaStoreChanged() {
}
fun getSongInfo(song: Song): String {
val file = File(song.data)
if (file.exists()) {
val audioHeader = AudioFileIO.read(File(song.data)).audioHeader
val string: StringBuilder = StringBuilder()
val uriFile = Uri.fromFile(file)
string.append(getMimeType(uriFile.toString())).append("")
string.append(audioHeader.bitRate).append(" kb/s").append("")
string.append(RetroUtil.frequencyCount(audioHeader.sampleRate.toInt())).append(" kHz")
return string.toString()
}
return "-"
}
private fun getMimeType(url: String): String? {
var type: String? = MimeTypeMap.getFileExtensionFromUrl(
URLEncoder.encode(url, "utf-8")
).toUpperCase(Locale.getDefault())
if (type == null) {
type = url.substring(url.lastIndexOf(".") + 1)
}
return type
} }
} }

View file

@ -9,7 +9,6 @@ import code.name.monkey.retromusic.fragments.VolumeFragment
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
/** /**
* Created by hemanths on 24/09/17. * Created by hemanths on 24/09/17.
*/ */
@ -38,18 +37,18 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgr
pivotY = (view.height / 2).toFloat() pivotY = (view.height / 2).toFloat()
animate().setDuration(200) animate().setDuration(200)
.setInterpolator(DecelerateInterpolator()) .setInterpolator(DecelerateInterpolator())
.scaleX(1.1f) .scaleX(1.1f)
.scaleY(1.1f) .scaleY(1.1f)
.withEndAction { .withEndAction {
animate().setDuration(200) animate().setDuration(200)
.setInterpolator(AccelerateInterpolator()) .setInterpolator(AccelerateInterpolator())
.scaleX(1f) .scaleX(1f)
.scaleY(1f) .scaleY(1f)
.alpha(1f) .alpha(1f)
.start() .start()
} }
.start() .start()
} }
} }
@ -71,6 +70,4 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgr
companion object { companion object {
const val SLIDER_ANIMATION_TIME: Long = 400 const val SLIDER_ANIMATION_TIME: Long = 400
} }
} }

View file

@ -11,7 +11,6 @@ import android.view.MenuItem;
import android.view.SubMenu; import android.view.SubMenu;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
@ -19,13 +18,6 @@ import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import com.afollestad.materialcab.MaterialCab;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.card.MaterialCardView;
import org.jetbrains.annotations.NotNull;
import code.name.monkey.appthemehelper.common.ATHToolbarActivity; import code.name.monkey.appthemehelper.common.ATHToolbarActivity;
import code.name.monkey.appthemehelper.util.ATHUtil; import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
@ -40,21 +32,29 @@ import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks;
import code.name.monkey.retromusic.util.NavigationUtil; import code.name.monkey.retromusic.util.NavigationUtil;
import code.name.monkey.retromusic.util.RetroColorUtil; import code.name.monkey.retromusic.util.RetroColorUtil;
import code.name.monkey.retromusic.util.RetroUtil; import code.name.monkey.retromusic.util.RetroUtil;
import com.afollestad.materialcab.MaterialCab;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.card.MaterialCardView;
import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.CompositeDisposable;
import org.jetbrains.annotations.NotNull;
public class LibraryFragment extends AbsMainActivityFragment implements CabHolder, MainActivityFragmentCallbacks { public class LibraryFragment extends AbsMainActivityFragment implements CabHolder, MainActivityFragmentCallbacks {
public static final String TAG = "LibraryFragment"; public static final String TAG = "LibraryFragment";
private static final String CURRENT_TAB_ID = "current_tab_id"; private static final String CURRENT_TAB_ID = "current_tab_id";
private Toolbar toolbar;
private AppBarLayout appBarLayout; private AppBarLayout appBarLayout;
private MaterialCardView toolbarContainer;
private MaterialCab cab; private MaterialCab cab;
private FragmentManager fragmentManager;
private CompositeDisposable disposable; private CompositeDisposable disposable;
private FragmentManager fragmentManager;
private Toolbar toolbar;
private MaterialCardView toolbarContainer;
@NonNull @NonNull
public static Fragment newInstance(int tab) { public static Fragment newInstance(int tab) {
@ -70,17 +70,11 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
return new LibraryFragment(); return new LibraryFragment();
} }
@Override
public void onDestroyView() {
super.onDestroyView();
disposable.dispose();
}
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_library, container, false); View view = inflater.inflate(R.layout.fragment_library, container, false);
disposable = new CompositeDisposable(); disposable = new CompositeDisposable();
appBarLayout = view.findViewById(R.id.appBarLayout); appBarLayout = view.findViewById(R.id.appBarLayout);
@ -89,23 +83,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
return view; return view;
} }
public void setTitle(@StringRes int name) {
toolbar.setTitle(getString(name));
}
public void addOnAppBarOffsetChangedListener(@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
appBarLayout.addOnOffsetChangedListener(onOffsetChangedListener);
}
public void removeOnAppBarOffsetChangedListener(@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
appBarLayout.removeOnOffsetChangedListener(onOffsetChangedListener);
}
public int getTotalAppBarScrollingRange() {
return appBarLayout.getTotalScrollRange();
}
@Override @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
@ -114,53 +91,19 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
inflateFragment(); inflateFragment();
} }
private void inflateFragment() { @Override
if (getArguments() == null) { public void onDestroyView() {
selectedFragment(SongsFragment.Companion.newInstance()); super.onDestroyView();
return; disposable.dispose();
}
switch (getArguments().getInt(CURRENT_TAB_ID)) {
default:
case R.id.action_song:
selectedFragment(SongsFragment.Companion.newInstance());
break;
case R.id.action_album:
selectedFragment(AlbumsFragment.Companion.newInstance());
break;
case R.id.action_artist:
selectedFragment(ArtistsFragment.Companion.newInstance());
break;
case R.id.action_playlist:
selectedFragment(PlaylistsFragment.Companion.newInstance());
break;
case R.id.action_genre:
selectedFragment(GenresFragment.Companion.newInstance());
break;
case R.id.action_playing_queue:
selectedFragment(PlayingQueueFragment.Companion.newInstance());
break;
}
} }
@SuppressWarnings("ConstantConditions") public void addOnAppBarOffsetChangedListener(
private void setupToolbar() { @NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
toolbar.setBackgroundTintList(ColorStateList.valueOf(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface))); appBarLayout.addOnOffsetChangedListener(onOffsetChangedListener);
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
toolbar.setOnClickListener(v -> {
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getMainActivity(), toolbarContainer, getString(R.string.transition_toolbar));
NavigationUtil.goToSearch(getMainActivity(), options);
});
getMainActivity().setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(v -> showMainMenu(OptionsSheetDialogFragment.LIBRARY));
ToolbarContentTintHelper.colorBackButton(toolbar);
//toolbar.setTitleTextColor(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorOnSecondary));
} }
private Fragment getCurrentFragment() { public int getTotalAppBarScrollingRange() {
if (fragmentManager == null) { return appBarLayout.getTotalScrollRange();
return SongsFragment.Companion.newInstance();
}
return fragmentManager.findFragmentByTag(LibraryFragment.TAG);
} }
@Override @Override
@ -172,31 +115,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
return false; return false;
} }
private void selectedFragment(Fragment fragment) {
fragmentManager = getChildFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction
.replace(R.id.fragmentContainer, fragment, LibraryFragment.TAG)
.commit();
}
@NonNull
@Override
public MaterialCab openCab(int menuRes, @NonNull MaterialCab.Callback callback) {
if (cab != null && cab.isActive()) {
cab.finish();
}
cab = new MaterialCab(getMainActivity(), R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface)))
.start(callback);
return cab;
}
@Override @Override
public void onCreateOptionsMenu(@NotNull Menu menu, @NonNull MenuInflater inflater) { public void onCreateOptionsMenu(@NotNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
@ -205,7 +123,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
Fragment currentFragment = getCurrentFragment(); Fragment currentFragment = getCurrentFragment();
if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment
&& currentFragment.isAdded()) { && currentFragment.isAdded()) {
AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment; AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment
= (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size); MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
if (RetroUtil.isLandscape()) { if (RetroUtil.isLandscape()) {
@ -220,10 +139,41 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
menu.removeItem(R.id.action_grid_size); menu.removeItem(R.id.action_grid_size);
menu.removeItem(R.id.action_sort_order); menu.removeItem(R.id.action_sort_order);
} else { } else {
menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title).setIcon(R.drawable.ic_playlist_add_white_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title)
.setIcon(R.drawable.ic_playlist_add_white_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
menu.removeItem(R.id.action_grid_size); menu.removeItem(R.id.action_grid_size);
} }
ToolbarContentTintHelper.handleOnCreateOptionsMenu(requireActivity(), toolbar, menu, ATHToolbarActivity.getToolbarBackgroundColor(toolbar)); ToolbarContentTintHelper.handleOnCreateOptionsMenu(requireActivity(), toolbar, menu,
ATHToolbarActivity.getToolbarBackgroundColor(toolbar));
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
//if (pager == null) return false;
Fragment currentFragment = getCurrentFragment();
if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment) {
AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment
= (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
if (handleGridSizeMenuItem(fragment, item)) {
return true;
}
if (handleSortOrderMenuItem(fragment, item)) {
return true;
}
}
int id = item.getItemId();
switch (id) {
case R.id.action_search:
ActivityOptions options = ActivityOptions
.makeSceneTransitionAnimation(getMainActivity(), toolbarContainer,
getString(R.string.transition_toolbar));
NavigationUtil.goToSearch(getMainActivity(), options);
break;
case R.id.action_new_playlist:
CreatePlaylistDialog.Companion.create().show(getChildFragmentManager(), "CREATE_PLAYLIST");
return true;
}
return super.onOptionsItemSelected(item);
} }
@Override @Override
@ -236,45 +186,76 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
ToolbarContentTintHelper.handleOnPrepareOptionsMenu(activity, toolbar); ToolbarContentTintHelper.handleOnPrepareOptionsMenu(activity, toolbar);
} }
@NonNull
private void setUpSortOrderMenu( @Override
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment, public MaterialCab openCab(int menuRes, @NonNull MaterialCab.Callback callback) {
@NonNull SubMenu sortOrderMenu) { if (cab != null && cab.isActive()) {
String currentSortOrder = fragment.getSortOrder(); cab.finish();
sortOrderMenu.clear();
if (fragment instanceof AlbumsFragment) {
sortOrderMenu.add(0, R.id.action_album_sort_order_asc, 0, R.string.sort_order_a_z)
.setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_A_Z));
sortOrderMenu.add(0, R.id.action_album_sort_order_desc, 1, R.string.sort_order_z_a)
.setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_Z_A));
sortOrderMenu.add(0, R.id.action_album_sort_order_artist, 2, R.string.sort_order_artist)
.setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_ARTIST));
sortOrderMenu.add(0, R.id.action_album_sort_order_year, 3, R.string.sort_order_year)
.setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_YEAR));
} else if (fragment instanceof ArtistsFragment) {
sortOrderMenu.add(0, R.id.action_artist_sort_order_asc, 0, R.string.sort_order_a_z)
.setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_A_Z));
sortOrderMenu.add(0, R.id.action_artist_sort_order_desc, 1, R.string.sort_order_z_a)
.setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_Z_A));
} else if (fragment instanceof SongsFragment) {
sortOrderMenu.add(0, R.id.action_song_sort_order_asc, 0, R.string.sort_order_a_z)
.setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_A_Z));
sortOrderMenu.add(0, R.id.action_song_sort_order_desc, 1, R.string.sort_order_z_a)
.setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_Z_A));
sortOrderMenu.add(0, R.id.action_song_sort_order_artist, 2, R.string.sort_order_artist)
.setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ARTIST));
sortOrderMenu.add(0, R.id.action_song_sort_order_album, 3, R.string.sort_order_album)
.setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ALBUM));
sortOrderMenu.add(0, R.id.action_song_sort_order_year, 4, R.string.sort_order_year)
.setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_YEAR));
sortOrderMenu.add(0, R.id.action_song_sort_order_date, 5, R.string.sort_order_date)
.setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_DATE));
sortOrderMenu.add(0, R.id.action_song_sort_order_composer, 6, R.string.sort_order_composer)
.setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.COMPOSER));
} }
sortOrderMenu.setGroupCheckable(0, true, true); cab = new MaterialCab(getMainActivity(), R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText(
ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface)))
.start(callback);
return cab;
}
public void removeOnAppBarOffsetChangedListener(
@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
appBarLayout.removeOnOffsetChangedListener(onOffsetChangedListener);
}
public void setTitle(@StringRes int name) {
toolbar.setTitle(getString(name));
}
private Fragment getCurrentFragment() {
if (fragmentManager == null) {
return SongsFragment.Companion.newInstance();
}
return fragmentManager.findFragmentByTag(LibraryFragment.TAG);
}
private boolean handleGridSizeMenuItem(
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment
fragment, @NonNull MenuItem item) {
int gridSize = 0;
switch (item.getItemId()) {
case R.id.action_grid_size_1:
gridSize = 1;
break;
case R.id.action_grid_size_2:
gridSize = 2;
break;
case R.id.action_grid_size_3:
gridSize = 3;
break;
case R.id.action_grid_size_4:
gridSize = 4;
break;
case R.id.action_grid_size_5:
gridSize = 5;
break;
case R.id.action_grid_size_6:
gridSize = 6;
break;
case R.id.action_grid_size_7:
gridSize = 7;
break;
case R.id.action_grid_size_8:
gridSize = 8;
break;
}
if (gridSize > 0) {
item.setChecked(true);
fragment.setAndSaveGridSize(gridSize);
return true;
}
return false;
} }
private boolean handleSortOrderMenuItem( private boolean handleSortOrderMenuItem(
@ -341,33 +322,41 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
return false; return false;
} }
private void inflateFragment() {
@Override if (getArguments() == null) {
public boolean onOptionsItemSelected(@NonNull MenuItem item) { selectedFragment(SongsFragment.Companion.newInstance());
//if (pager == null) return false; return;
Fragment currentFragment = getCurrentFragment();
if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment) {
AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
if (handleGridSizeMenuItem(fragment, item)) {
return true;
}
if (handleSortOrderMenuItem(fragment, item)) {
return true;
}
} }
int id = item.getItemId(); switch (getArguments().getInt(CURRENT_TAB_ID)) {
switch (id) { default:
case R.id.action_search: case R.id.action_song:
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getMainActivity(), toolbarContainer, getString(R.string.transition_toolbar)); selectedFragment(SongsFragment.Companion.newInstance());
NavigationUtil.goToSearch(getMainActivity(), options); break;
case R.id.action_album:
selectedFragment(AlbumsFragment.Companion.newInstance());
break;
case R.id.action_artist:
selectedFragment(ArtistsFragment.Companion.newInstance());
break;
case R.id.action_playlist:
selectedFragment(PlaylistsFragment.Companion.newInstance());
break;
case R.id.action_genre:
selectedFragment(GenresFragment.Companion.newInstance());
break;
case R.id.action_playing_queue:
selectedFragment(PlayingQueueFragment.Companion.newInstance());
break; break;
case R.id.action_new_playlist:
CreatePlaylistDialog.Companion.create().show(getChildFragmentManager(), "CREATE_PLAYLIST");
return true;
} }
return super.onOptionsItemSelected(item);
} }
private void selectedFragment(Fragment fragment) {
fragmentManager = getChildFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction
.replace(R.id.fragmentContainer, fragment, LibraryFragment.TAG)
.commit();
}
private void setUpGridSizeMenu( private void setUpGridSizeMenu(
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment, @NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
@ -419,43 +408,60 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
} }
} }
private void setUpSortOrderMenu(
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
@NonNull SubMenu sortOrderMenu) {
String currentSortOrder = fragment.getSortOrder();
sortOrderMenu.clear();
private boolean handleGridSizeMenuItem( if (fragment instanceof AlbumsFragment) {
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment sortOrderMenu.add(0, R.id.action_album_sort_order_asc, 0, R.string.sort_order_a_z)
fragment, @NonNull MenuItem item) { .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_A_Z));
int gridSize = 0; sortOrderMenu.add(0, R.id.action_album_sort_order_desc, 1, R.string.sort_order_z_a)
switch (item.getItemId()) { .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_Z_A));
case R.id.action_grid_size_1: sortOrderMenu.add(0, R.id.action_album_sort_order_artist, 2, R.string.sort_order_artist)
gridSize = 1; .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_ARTIST));
break; sortOrderMenu.add(0, R.id.action_album_sort_order_year, 3, R.string.sort_order_year)
case R.id.action_grid_size_2: .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_YEAR));
gridSize = 2; } else if (fragment instanceof ArtistsFragment) {
break; sortOrderMenu.add(0, R.id.action_artist_sort_order_asc, 0, R.string.sort_order_a_z)
case R.id.action_grid_size_3: .setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_A_Z));
gridSize = 3; sortOrderMenu.add(0, R.id.action_artist_sort_order_desc, 1, R.string.sort_order_z_a)
break; .setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_Z_A));
case R.id.action_grid_size_4: } else if (fragment instanceof SongsFragment) {
gridSize = 4; sortOrderMenu.add(0, R.id.action_song_sort_order_asc, 0, R.string.sort_order_a_z)
break; .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_A_Z));
case R.id.action_grid_size_5: sortOrderMenu.add(0, R.id.action_song_sort_order_desc, 1, R.string.sort_order_z_a)
gridSize = 5; .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_Z_A));
break; sortOrderMenu.add(0, R.id.action_song_sort_order_artist, 2, R.string.sort_order_artist)
case R.id.action_grid_size_6: .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ARTIST));
gridSize = 6; sortOrderMenu.add(0, R.id.action_song_sort_order_album, 3, R.string.sort_order_album)
break; .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ALBUM));
case R.id.action_grid_size_7: sortOrderMenu.add(0, R.id.action_song_sort_order_year, 4, R.string.sort_order_year)
gridSize = 7; .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_YEAR));
break; sortOrderMenu.add(0, R.id.action_song_sort_order_date, 5, R.string.sort_order_date)
case R.id.action_grid_size_8: .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_DATE));
gridSize = 8; sortOrderMenu.add(0, R.id.action_song_sort_order_composer, 6, R.string.sort_order_composer)
break; .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.COMPOSER));
} }
if (gridSize > 0) { sortOrderMenu.setGroupCheckable(0, true, true);
item.setChecked(true); }
fragment.setAndSaveGridSize(gridSize);
return true; @SuppressWarnings("ConstantConditions")
} private void setupToolbar() {
return false; toolbar.setBackgroundTintList(
ColorStateList.valueOf(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface)));
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
toolbar.setOnClickListener(v -> {
ActivityOptions options = ActivityOptions
.makeSceneTransitionAnimation(getMainActivity(), toolbarContainer,
getString(R.string.transition_toolbar));
NavigationUtil.goToSearch(getMainActivity(), options);
});
getMainActivity().setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(v -> showMainMenu(OptionsSheetDialogFragment.LIBRARY));
//ToolbarContentTintHelper.colorBackButton(toolbar);
//toolbar.setTitleTextColor(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorOnSecondary));
} }
} }

View file

@ -18,7 +18,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
import code.name.monkey.retromusic.model.lyrics.Lyrics import code.name.monkey.retromusic.model.lyrics.Lyrics
import kotlinx.android.synthetic.main.fragment_adaptive_player.* import kotlinx.android.synthetic.main.fragment_adaptive_player.playerToolbar
class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback { class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
@ -53,7 +53,10 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
lyricsLine1.visibility = View.VISIBLE lyricsLine1.visibility = View.VISIBLE
lyricsLine2.visibility = View.VISIBLE lyricsLine2.visibility = View.VISIBLE
lyricsLine2.measure(View.MeasureSpec.makeMeasureSpec(lyricsLine2.measuredWidth, View.MeasureSpec.EXACTLY), View.MeasureSpec.UNSPECIFIED) lyricsLine2.measure(
View.MeasureSpec.makeMeasureSpec(lyricsLine2.measuredWidth, View.MeasureSpec.EXACTLY),
View.MeasureSpec.UNSPECIFIED
)
val h: Float = lyricsLine2.measuredHeight.toFloat() val h: Float = lyricsLine2.measuredHeight.toFloat()
lyricsLine1.alpha = 1f lyricsLine1.alpha = 1f
@ -130,8 +133,10 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as AdaptivePlaybackControlsFragment playbackControlsFragment =
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as AdaptivePlaybackControlsFragment
val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.apply { playerAlbumCoverFragment.apply {
removeSlideEffect() removeSlideEffect()
setCallbacks(this@AdaptiveFragment) setCallbacks(this@AdaptiveFragment)
@ -184,7 +189,11 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color)
lastColor = color lastColor = color
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
requireActivity()
)
} }
override fun onShow() { override fun onShow() {
@ -206,5 +215,4 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
override val paletteColor: Int override val paletteColor: Int
get() = lastColor get() = lastColor
} }

View file

@ -14,17 +14,26 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.nextButton
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.playPauseButton
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.previousButton
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.progressSlider
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.repeatButton
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.shuffleButton
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.songTotalTime
class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() { class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -37,8 +46,10 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this) progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_adaptive_player_playback_controls, container, false) return inflater.inflate(R.layout.fragment_adaptive_player_playback_controls, container, false)
} }
@ -56,6 +67,14 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
} }
private fun updateSong() {
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong)
} else {
songInfo?.hide()
}
}
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
progressViewUpdateHelper!!.start() progressViewUpdateHelper!!.start()
@ -66,10 +85,16 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper!!.stop() progressViewUpdateHelper!!.stop()
} }
override fun onPlayingMetaChanged() {
super.onPlayingMetaChanged()
updateSong()
}
override fun onServiceConnected() { override fun onServiceConnected() {
updatePlayPauseDrawableState() updatePlayPauseDrawableState()
updateRepeatState() updateRepeatState()
updateShuffleState() updateShuffleState()
updateSong()
} }
override fun onPlayStateChanged() { override fun onPlayStateChanged() {
@ -104,7 +129,11 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
ThemeStore.accentColor(context!!) ThemeStore.accentColor(context!!)
}.ripAlpha() }.ripAlpha()
TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(colorFinal)), false) TintHelper.setTintAuto(
playPauseButton,
MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(colorFinal)),
false
)
TintHelper.setTintAuto(playPauseButton, colorFinal, true) TintHelper.setTintAuto(playPauseButton, colorFinal, true)
ViewUtil.setProgressDrawable(progressSlider, colorFinal, true) ViewUtil.setProgressDrawable(progressSlider, colorFinal, true)
volumeFragment?.setTintable(colorFinal) volumeFragment?.setTintable(colorFinal)
@ -151,7 +180,10 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -202,8 +234,10 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) { if (fromUser) {
MusicPlayerRemote.seekTo(progress) MusicPlayerRemote.seekTo(progress)
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis, onUpdateProgressViews(
MusicPlayerRemote.songDurationMillis) MusicPlayerRemote.songProgressMillis,
MusicPlayerRemote.songDurationMillis
)
} }
} }
}) })

View file

@ -16,6 +16,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
@ -23,7 +24,18 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.* import code.name.monkey.retromusic.util.PreferenceUtil
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.nextButton
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.playPauseButton
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.previousButton
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.progressSlider
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.repeatButton
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.shuffleButton
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.songTotalTime
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.text
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.title
class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() { class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -36,9 +48,10 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this) progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
} }
override fun onCreateView(inflater: LayoutInflater, override fun onCreateView(
container: ViewGroup?, inflater: LayoutInflater,
savedInstanceState: Bundle? container: ViewGroup?,
savedInstanceState: Bundle?
): View? { ): View? {
return inflater.inflate(R.layout.fragment_blur_player_playback_controls, container, false) return inflater.inflate(R.layout.fragment_blur_player_playback_controls, container, false)
} }
@ -63,6 +76,12 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = "${song.artistName}${song.albumName}" text.text = "${song.artistName}${song.albumName}"
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
} }
override fun onResume() { override fun onResume() {
@ -120,7 +139,11 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
private fun setFabColor(i: Int) { private fun setFabColor(i: Int) {
TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(i)), false) TintHelper.setTintAuto(
playPauseButton,
MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(i)),
false
)
TintHelper.setTintAuto(playPauseButton, i, true) TintHelper.setTintAuto(playPauseButton, i, true)
} }
@ -161,7 +184,10 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -189,11 +215,11 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
public override fun show() { public override fun show() {
playPauseButton!!.animate() playPauseButton!!.animate()
.scaleX(1f) .scaleX(1f)
.scaleY(1f) .scaleY(1f)
.rotation(360f) .rotation(360f)
.setInterpolator(DecelerateInterpolator()) .setInterpolator(DecelerateInterpolator())
.start() .start()
} }
public override fun hide() { public override fun hide() {
@ -211,8 +237,10 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) { if (fromUser) {
MusicPlayerRemote.seekTo(progress) MusicPlayerRemote.seekTo(progress)
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis, onUpdateProgressViews(
MusicPlayerRemote.songDurationMillis) MusicPlayerRemote.songProgressMillis,
MusicPlayerRemote.songDurationMillis
)
} }
} }
}) })
@ -228,20 +256,19 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
pivotY = (height / 2).toFloat() pivotY = (height / 2).toFloat()
animate().setDuration(200) animate().setDuration(200)
.setInterpolator(DecelerateInterpolator()) .setInterpolator(DecelerateInterpolator())
.scaleX(1.1f) .scaleX(1.1f)
.scaleY(1.1f) .scaleY(1.1f)
.withEndAction { .withEndAction {
animate().setDuration(200) animate().setDuration(200)
.setInterpolator(AccelerateInterpolator()) .setInterpolator(AccelerateInterpolator())
.scaleX(1f) .scaleX(1f)
.scaleY(1f) .scaleY(1f)
.alpha(1f).start() .alpha(1f).start()
}.start() }.start()
} }
} }
override fun onUpdateProgressViews(progress: Int, total: Int) { override fun onUpdateProgressViews(progress: Int, total: Int) {
progressSlider.max = total progressSlider.max = total

View file

@ -19,7 +19,8 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_blur.* import kotlinx.android.synthetic.main.fragment_blur.colorBackground
import kotlinx.android.synthetic.main.fragment_blur.playerToolbar
class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener { class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
@ -31,9 +32,10 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
private var lastColor: Int = 0 private var lastColor: Int = 0
override fun onCreateView(
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_blur, container, false) return inflater.inflate(R.layout.fragment_blur, container, false)
} }
@ -44,8 +46,10 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as BlurPlaybackControlsFragment playbackControlsFragment =
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as BlurPlaybackControlsFragment
val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
} }
@ -76,11 +80,9 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
} }
override fun onShow() { override fun onShow() {
} }
override fun onHide() { override fun onHide() {
} }
override fun onBackPressed(): Boolean { override fun onBackPressed(): Boolean {
@ -94,24 +96,23 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
override val paletteColor: Int override val paletteColor: Int
get() = lastColor get() = lastColor
private fun updateBlur() { private fun updateBlur() {
val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext()) val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
.getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25) .getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
colorBackground!!.clearColorFilter() colorBackground!!.clearColorFilter()
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong) SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext()) .checkIgnoreMediaStore(requireContext())
.generatePalette(requireContext()).build() .generatePalette(requireContext()).build()
.transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build()) .transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build())
//.centerCrop() //.centerCrop()
//.override(320, 480) //.override(320, 480)
.into(object : RetroMusicColoredTarget(colorBackground) { .into(object : RetroMusicColoredTarget(colorBackground) {
override fun onColorReady(color: Int) { override fun onColorReady(color: Int) {
if (color == defaultFooterColor) { if (color == defaultFooterColor) {
colorBackground!!.setColorFilter(color) colorBackground!!.setColorFilter(color)
}
} }
}) }
})
} }
override fun onServiceConnected() { override fun onServiceConnected() {
@ -131,7 +132,8 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
PreferenceManager.getDefaultSharedPreferences(requireContext()).unregisterOnSharedPreferenceChangeListener(this) PreferenceManager.getDefaultSharedPreferences(requireContext())
.unregisterOnSharedPreferenceChangeListener(this)
} }
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
@ -139,6 +141,5 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
updateBlur() updateBlur()
} }
} }
} }

View file

@ -13,7 +13,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import kotlinx.android.synthetic.main.fragment_card_player.* import kotlinx.android.synthetic.main.fragment_card_player.playerToolbar
class CardFragment : AbsPlayerFragment() { class CardFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
@ -62,8 +62,10 @@ class CardFragment : AbsPlayerFragment() {
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_card_player, container, false) return inflater.inflate(R.layout.fragment_card_player, container, false)
} }
@ -75,8 +77,10 @@ class CardFragment : AbsPlayerFragment() {
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardPlaybackControlsFragment playbackControlsFragment =
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardPlaybackControlsFragment
val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
playerAlbumCoverFragment.removeSlideEffect() playerAlbumCoverFragment.removeSlideEffect()
} }
@ -87,7 +91,6 @@ class CardFragment : AbsPlayerFragment() {
playerToolbar.setOnMenuItemClickListener(this) playerToolbar.setOnMenuItemClickListener(this)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
} }
override fun onServiceConnected() { override fun onServiceConnected() {
@ -107,6 +110,4 @@ class CardFragment : AbsPlayerFragment() {
return fragment return fragment
} }
} }
} }

View file

@ -14,6 +14,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -23,8 +24,18 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.image
import kotlinx.android.synthetic.main.media_button.* import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.progressSlider
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.songTotalTime
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.text
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.title
import kotlinx.android.synthetic.main.media_button.nextButton
import kotlinx.android.synthetic.main.media_button.playPauseButton
import kotlinx.android.synthetic.main.media_button.previousButton
import kotlinx.android.synthetic.main.media_button.repeatButton
import kotlinx.android.synthetic.main.media_button.shuffleButton
class CardPlaybackControlsFragment : AbsPlayerControlsFragment() { class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -32,14 +43,15 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
private var lastDisabledPlaybackControlsColor: Int = 0 private var lastDisabledPlaybackControlsColor: Int = 0
private var progressViewUpdateHelper: MusicProgressViewUpdateHelper? = null private var progressViewUpdateHelper: MusicProgressViewUpdateHelper? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this) progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_card_player_playback_controls, container, false) return inflater.inflate(R.layout.fragment_card_player_playback_controls, container, false)
} }
@ -64,6 +76,11 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong)
} else {
songInfo?.hide()
}
} }
override fun onResume() { override fun onResume() {
@ -116,18 +133,20 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
updatePlayPauseColor() updatePlayPauseColor()
updateProgressTextColor() updateProgressTextColor()
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!).ripAlpha() ThemeStore.accentColor(context!!).ripAlpha()
} }
image.setColorFilter(colorFinal, PorterDuff.Mode.SRC_IN) image.setColorFilter(colorFinal, PorterDuff.Mode.SRC_IN)
TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(colorFinal)), false) TintHelper.setTintAuto(
playPauseButton,
MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(colorFinal)),
false
)
TintHelper.setTintAuto(playPauseButton, colorFinal, true) TintHelper.setTintAuto(playPauseButton, colorFinal, true)
volumeFragment?.setTintable(colorFinal) volumeFragment?.setTintable(colorFinal)
} }
private fun updatePlayPauseColor() { private fun updatePlayPauseColor() {
@ -171,7 +190,10 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -20,7 +20,8 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_card_blur_player.* import kotlinx.android.synthetic.main.fragment_card_blur_player.colorBackground
import kotlinx.android.synthetic.main.fragment_card_blur_player.playerToolbar
class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener { class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
@ -32,7 +33,6 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
get() = lastColor get() = lastColor
private lateinit var playbackControlsFragment: CardBlurPlaybackControlsFragment private lateinit var playbackControlsFragment: CardBlurPlaybackControlsFragment
override fun onShow() { override fun onShow() {
playbackControlsFragment.show() playbackControlsFragment.show()
} }
@ -71,9 +71,10 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
override fun onCreateView(
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_card_blur_player, container, false) return inflater.inflate(R.layout.fragment_card_blur_player, container, false)
} }
@ -85,13 +86,14 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardBlurPlaybackControlsFragment playbackControlsFragment =
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment? childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardBlurPlaybackControlsFragment
val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment?
if (playerAlbumCoverFragment != null) { if (playerAlbumCoverFragment != null) {
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
playerAlbumCoverFragment.removeEffect() playerAlbumCoverFragment.removeEffect()
} }
} }
private fun setUpPlayerToolbar() { private fun setUpPlayerToolbar() {
@ -126,21 +128,21 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
private fun updateBlur() { private fun updateBlur() {
val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext()) val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
.getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25) .getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
colorBackground!!.clearColorFilter() colorBackground!!.clearColorFilter()
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong) SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext()) .checkIgnoreMediaStore(requireContext())
.generatePalette(requireContext()).build() .generatePalette(requireContext()).build()
.transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build()) .transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build())
//.centerCrop() //.centerCrop()
//.override(320, 480) //.override(320, 480)
.into(object : RetroMusicColoredTarget(colorBackground) { .into(object : RetroMusicColoredTarget(colorBackground) {
override fun onColorReady(color: Int) { override fun onColorReady(color: Int) {
if (color == defaultFooterColor) { if (color == defaultFooterColor) {
colorBackground!!.setColorFilter(color) colorBackground!!.setColorFilter(color)
}
} }
}) }
})
} }
override fun onResume() { override fun onResume() {
@ -150,7 +152,8 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
PreferenceManager.getDefaultSharedPreferences(requireContext()).unregisterOnSharedPreferenceChangeListener(this) PreferenceManager.getDefaultSharedPreferences(requireContext())
.unregisterOnSharedPreferenceChangeListener(this)
} }
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {

View file

@ -14,6 +14,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
@ -21,10 +22,17 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.progressSlider
import kotlinx.android.synthetic.main.media_button.* import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.songTotalTime
import kotlinx.android.synthetic.main.media_button.nextButton
import kotlinx.android.synthetic.main.media_button.playPauseButton
import kotlinx.android.synthetic.main.media_button.previousButton
import kotlinx.android.synthetic.main.media_button.repeatButton
import kotlinx.android.synthetic.main.media_button.shuffleButton
class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() { class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -32,14 +40,15 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
private var lastDisabledPlaybackControlsColor: Int = 0 private var lastDisabledPlaybackControlsColor: Int = 0
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this) progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_card_blur_player_playback_controls, container, false) return inflater.inflate(R.layout.fragment_card_blur_player_playback_controls, container, false)
} }
@ -62,7 +71,6 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
volumeFragment?.tintWhiteColor() volumeFragment?.tintWhiteColor()
} }
private fun setUpPlayPauseFab() { private fun setUpPlayPauseFab() {
playPauseButton.apply { playPauseButton.apply {
TintHelper.setTintAuto(this, Color.WHITE, true) TintHelper.setTintAuto(this, Color.WHITE, true)
@ -78,14 +86,12 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
} }
private fun updateProgressTextColor() { private fun updateProgressTextColor() {
val color = MaterialValueHelper.getPrimaryTextColor(context, false) val color = MaterialValueHelper.getPrimaryTextColor(context, false)
songTotalTime.setTextColor(color) songTotalTime.setTextColor(color)
songCurrentProgress.setTextColor(color) songCurrentProgress.setTextColor(color)
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
progressViewUpdateHelper.start() progressViewUpdateHelper.start()
@ -100,6 +106,15 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
updatePlayPauseDrawableState() updatePlayPauseDrawableState()
updateRepeatState() updateRepeatState()
updateShuffleState() updateShuffleState()
updateSong()
}
private fun updateSong() {
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong)
} else {
songInfo?.hide()
}
} }
override fun onPlayStateChanged() { override fun onPlayStateChanged() {
@ -139,7 +154,10 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -167,11 +185,11 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
public override fun show() { public override fun show() {
playPauseButton!!.animate() playPauseButton!!.animate()
.scaleX(1f) .scaleX(1f)
.scaleY(1f) .scaleY(1f)
.rotation(360f) .rotation(360f)
.setInterpolator(DecelerateInterpolator()) .setInterpolator(DecelerateInterpolator())
.start() .start()
} }
public override fun hide() { public override fun hide() {
@ -189,14 +207,15 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) { if (fromUser) {
MusicPlayerRemote.seekTo(progress) MusicPlayerRemote.seekTo(progress)
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis, onUpdateProgressViews(
MusicPlayerRemote.songDurationMillis) MusicPlayerRemote.songProgressMillis,
MusicPlayerRemote.songDurationMillis
)
} }
} }
}) })
} }
override fun onUpdateProgressViews(progress: Int, total: Int) { override fun onUpdateProgressViews(progress: Int, total: Int) {
progressSlider.max = total progressSlider.max = total

View file

@ -13,6 +13,7 @@ import android.widget.SeekBar
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
@ -20,6 +21,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.nextButton import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.nextButton
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.playPauseButton import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.playPauseButton
@ -28,6 +30,7 @@ import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.pr
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.repeatButton import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.repeatButton
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.shuffleButton import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.shuffleButton
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.songCurrentProgress import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.songTotalTime import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.songTotalTime
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.text import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.text
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.title import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.title
@ -68,6 +71,12 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
} }
override fun onServiceConnected() { override fun onServiceConnected() {
@ -104,8 +113,9 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
lastPlaybackControlsColor = color lastPlaybackControlsColor = color
lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color, 0.5f) lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color, 0.5f)
title!!.setTextColor(lastPlaybackControlsColor) title.setTextColor(lastPlaybackControlsColor)
text!!.setTextColor(lastDisabledPlaybackControlsColor) text.setTextColor(lastDisabledPlaybackControlsColor)
songInfo.setTextColor(lastDisabledPlaybackControlsColor)
ViewUtil.setProgressDrawable(progressSlider, lastPlaybackControlsColor, true) ViewUtil.setProgressDrawable(progressSlider, lastPlaybackControlsColor, true)

View file

@ -12,8 +12,7 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import kotlinx.android.synthetic.main.fragment_fit.* import kotlinx.android.synthetic.main.fragment_fit.playerToolbar
class FitFragment : AbsPlayerFragment() { class FitFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
@ -47,7 +46,11 @@ class FitFragment : AbsPlayerFragment() {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color)
lastColor = color lastColor = color
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
requireActivity()
)
} }
override fun toggleFavorite(song: Song) { override fun toggleFavorite(song: Song) {
@ -61,8 +64,10 @@ class FitFragment : AbsPlayerFragment() {
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_fit, container, false) return inflater.inflate(R.layout.fragment_fit, container, false)
} }
@ -74,8 +79,10 @@ class FitFragment : AbsPlayerFragment() {
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FitPlaybackControlsFragment playbackControlsFragment =
val playerAlbumCoverFragment: PlayerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FitPlaybackControlsFragment
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
playerAlbumCoverFragment.removeEffect() playerAlbumCoverFragment.removeEffect()
} }
@ -85,7 +92,11 @@ class FitFragment : AbsPlayerFragment() {
inflateMenu(R.menu.menu_player) inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { requireActivity().onBackPressed() } setNavigationOnClickListener { requireActivity().onBackPressed() }
setOnMenuItemClickListener(this@FitFragment) setOnMenuItemClickListener(this@FitFragment)
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
this,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
requireActivity()
)
} }
} }

View file

@ -3,19 +3,40 @@ package code.name.monkey.retromusic.fragments.player.fit
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.graphics.PorterDuff import android.graphics.PorterDuff
import android.os.Bundle import android.os.Bundle
import android.view.* import android.view.LayoutInflater
import android.view.animation.* import android.view.View
import android.view.ViewGroup
import android.view.animation.AccelerateInterpolator
import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator
import android.widget.SeekBar import android.widget.SeekBar
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.* import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.* import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.* import code.name.monkey.retromusic.util.MusicUtil
import kotlinx.android.synthetic.main.fragment_player_playback_controls.* import code.name.monkey.retromusic.util.PreferenceUtil
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.nextButton
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.playPauseButton
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.previousButton
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.progressSlider
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.repeatButton
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.shuffleButton
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.songTotalTime
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.text
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.title
class FitPlaybackControlsFragment : AbsPlayerControlsFragment() { class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
@ -24,14 +45,15 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
private var lastDisabledPlaybackControlsColor: Int = 0 private var lastDisabledPlaybackControlsColor: Int = 0
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this) progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_fit_playback_controls, container, false) return inflater.inflate(R.layout.fragment_fit_playback_controls, container, false)
} }
@ -57,6 +79,11 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
} }
override fun onResume() { override fun onResume() {
@ -118,7 +145,11 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
private fun setFabColor(i: Int) { private fun setFabColor(i: Int) {
TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(i)), false) TintHelper.setTintAuto(
playPauseButton,
MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(i)),
false
)
TintHelper.setTintAuto(playPauseButton, i, true) TintHelper.setTintAuto(playPauseButton, i, true)
} }
@ -159,7 +190,10 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -187,11 +221,11 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
public override fun show() { public override fun show() {
playPauseButton!!.animate() playPauseButton!!.animate()
.scaleX(1f) .scaleX(1f)
.scaleY(1f) .scaleY(1f)
.rotation(360f) .rotation(360f)
.setInterpolator(DecelerateInterpolator()) .setInterpolator(DecelerateInterpolator())
.start() .start()
} }
public override fun hide() { public override fun hide() {
@ -209,8 +243,10 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) { if (fromUser) {
MusicPlayerRemote.seekTo(progress) MusicPlayerRemote.seekTo(progress)
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis, onUpdateProgressViews(
MusicPlayerRemote.songDurationMillis) MusicPlayerRemote.songProgressMillis,
MusicPlayerRemote.songDurationMillis
)
} }
} }
}) })
@ -226,16 +262,16 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
pivotY = (height / 2).toFloat() pivotY = (height / 2).toFloat()
animate().setDuration(200) animate().setDuration(200)
.setInterpolator(DecelerateInterpolator()) .setInterpolator(DecelerateInterpolator())
.scaleX(1.1f) .scaleX(1.1f)
.scaleY(1.1f) .scaleY(1.1f)
.withEndAction { .withEndAction {
animate().setDuration(200) animate().setDuration(200)
.setInterpolator(AccelerateInterpolator()) .setInterpolator(AccelerateInterpolator())
.scaleX(1f) .scaleX(1f)
.scaleY(1f) .scaleY(1f)
.alpha(1f).start() .alpha(1f).start()
}.start() }.start()
} }
} }
@ -250,5 +286,4 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong()) songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong()) songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
} }
} }

View file

@ -15,6 +15,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -26,7 +27,15 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.playPauseButton
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.progressSlider
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.repeatButton
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.shuffleButton
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.songTotalTime
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.text
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.title
class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback { class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
@ -34,14 +43,15 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
private var lastDisabledPlaybackControlsColor: Int = 0 private var lastDisabledPlaybackControlsColor: Int = 0
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this) progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_flat_player_playback_controls, container, false) return inflater.inflate(R.layout.fragment_flat_player_playback_controls, container, false)
} }
@ -76,13 +86,12 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
public override fun show() { public override fun show() {
playPauseButton!!.animate() playPauseButton!!.animate()
.scaleX(1f) .scaleX(1f)
.scaleY(1f) .scaleY(1f)
.setInterpolator(DecelerateInterpolator()) .setInterpolator(DecelerateInterpolator())
.start() .start()
} }
public override fun hide() { public override fun hide() {
playPauseButton!!.apply { playPauseButton!!.apply {
scaleX = 0f scaleX = 0f
@ -130,6 +139,8 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
title.setTextColor(colorPrimary) title.setTextColor(colorPrimary)
text.setBackgroundColor(darkColor) text.setBackgroundColor(darkColor)
text.setTextColor(colorSecondary) text.setTextColor(colorSecondary)
songInfo.setBackgroundColor(darkColor)
songInfo.setTextColor(colorSecondary)
} }
override fun onServiceConnected() { override fun onServiceConnected() {
@ -172,7 +183,11 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
} }
override fun setUpProgressSlider() { override fun setUpProgressSlider() {
@ -180,8 +195,10 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) { if (fromUser) {
MusicPlayerRemote.seekTo(progress) MusicPlayerRemote.seekTo(progress)
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis, onUpdateProgressViews(
MusicPlayerRemote.songDurationMillis) MusicPlayerRemote.songProgressMillis,
MusicPlayerRemote.songDurationMillis
)
} }
} }
}) })
@ -222,9 +239,11 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
} }

View file

@ -20,7 +20,8 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.views.DrawableGradient import code.name.monkey.retromusic.views.DrawableGradient
import kotlinx.android.synthetic.main.fragment_flat_player.* import kotlinx.android.synthetic.main.fragment_flat_player.colorGradientBackground
import kotlinx.android.synthetic.main.fragment_flat_player.playerToolbar
class FlatPlayerFragment : AbsPlayerFragment() { class FlatPlayerFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
@ -34,8 +35,10 @@ class FlatPlayerFragment : AbsPlayerFragment() {
get() = lastColor get() = lastColor
private fun setUpSubFragments() { private fun setUpSubFragments() {
flatPlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FlatPlaybackControlsFragment flatPlaybackControlsFragment =
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FlatPlaybackControlsFragment
val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
} }
@ -43,7 +46,11 @@ class FlatPlayerFragment : AbsPlayerFragment() {
playerToolbar.inflateMenu(R.menu.menu_player) playerToolbar.inflateMenu(R.menu.menu_player)
playerToolbar.setNavigationOnClickListener { _ -> requireActivity().onBackPressed() } playerToolbar.setNavigationOnClickListener { _ -> requireActivity().onBackPressed() }
playerToolbar.setOnMenuItemClickListener(this) playerToolbar.setOnMenuItemClickListener(this)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
requireActivity()
)
} }
private fun colorize(i: Int) { private fun colorize(i: Int) {
@ -53,16 +60,20 @@ class FlatPlayerFragment : AbsPlayerFragment() {
valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), android.R.color.transparent, i) valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), android.R.color.transparent, i)
valueAnimator!!.addUpdateListener { animation -> valueAnimator!!.addUpdateListener { animation ->
val drawable = DrawableGradient(GradientDrawable.Orientation.TOP_BOTTOM, val drawable = DrawableGradient(
intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0) GradientDrawable.Orientation.TOP_BOTTOM,
intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0
)
colorGradientBackground?.background = drawable colorGradientBackground?.background = drawable
} }
valueAnimator!!.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()).start() valueAnimator!!.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()).start()
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_flat_player, container, false) return inflater.inflate(R.layout.fragment_flat_player, container, false)
} }
@ -70,7 +81,6 @@ class FlatPlayerFragment : AbsPlayerFragment() {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setUpPlayerToolbar() setUpPlayerToolbar()
setUpSubFragments() setUpSubFragments()
} }
override fun onShow() { override fun onShow() {
@ -109,12 +119,10 @@ class FlatPlayerFragment : AbsPlayerFragment() {
} }
} }
override fun onFavoriteToggled() { override fun onFavoriteToggled() {
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
override fun toggleFavorite(song: Song) { override fun toggleFavorite(song: Song) {
super.toggleFavorite(song) super.toggleFavorite(song)
if (song.id == MusicPlayerRemote.currentSong.id) { if (song.id == MusicPlayerRemote.currentSong.id) {

View file

@ -21,6 +21,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -32,7 +33,19 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_full_player_controls.* import kotlinx.android.synthetic.main.fragment_full_player_controls.nextButton
import kotlinx.android.synthetic.main.fragment_full_player_controls.playPauseButton
import kotlinx.android.synthetic.main.fragment_full_player_controls.playerMenu
import kotlinx.android.synthetic.main.fragment_full_player_controls.previousButton
import kotlinx.android.synthetic.main.fragment_full_player_controls.progressSlider
import kotlinx.android.synthetic.main.fragment_full_player_controls.repeatButton
import kotlinx.android.synthetic.main.fragment_full_player_controls.shuffleButton
import kotlinx.android.synthetic.main.fragment_full_player_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_full_player_controls.songFavourite
import kotlinx.android.synthetic.main.fragment_full_player_controls.songInfo
import kotlinx.android.synthetic.main.fragment_full_player_controls.songTotalTime
import kotlinx.android.synthetic.main.fragment_full_player_controls.text
import kotlinx.android.synthetic.main.fragment_full_player_controls.title
/** /**
* Created by hemanths on 20/09/17. * Created by hemanths on 20/09/17.
@ -49,13 +62,14 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this) progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
} }
override fun onCreateView(inflater: LayoutInflater, override fun onCreateView(
container: ViewGroup?, inflater: LayoutInflater,
savedInstanceState: Bundle?): View? { container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_full_player_controls, container, false) return inflater.inflate(R.layout.fragment_full_player_controls, container, false)
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setUpMusicControllers() setUpMusicControllers()
@ -90,13 +104,12 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
public override fun show() { public override fun show() {
playPauseButton!!.animate() playPauseButton!!.animate()
.scaleX(1f) .scaleX(1f)
.scaleY(1f) .scaleY(1f)
.setInterpolator(DecelerateInterpolator()) .setInterpolator(DecelerateInterpolator())
.start() .start()
} }
public override fun hide() { public override fun hide() {
playPauseButton.apply { playPauseButton.apply {
scaleX = 0f scaleX = 0f
@ -120,12 +133,16 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
ViewUtil.setProgressDrawable(progressSlider, colorFinal, true) ViewUtil.setProgressDrawable(progressSlider, colorFinal, true)
playPauseButton.backgroundTintList = ColorStateList.valueOf(colorFinal) playPauseButton.backgroundTintList = ColorStateList.valueOf(colorFinal)
playPauseButton.imageTintList = ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(colorFinal))) playPauseButton.imageTintList = ColorStateList.valueOf(
MaterialValueHelper.getPrimaryTextColor(
context,
ColorUtil.isColorLight(colorFinal)
)
)
updateRepeatState() updateRepeatState()
updateShuffleState() updateShuffleState()
updatePrevNextColor() updatePrevNextColor()
} }
override fun onServiceConnected() { override fun onServiceConnected() {
@ -140,6 +157,11 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
updateIsFavorite() updateIsFavorite()
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
} }
override fun onPlayingMetaChanged() { override fun onPlayingMetaChanged() {
@ -199,7 +221,6 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
previousButton.setOnClickListener { MusicPlayerRemote.back() } previousButton.setOnClickListener { MusicPlayerRemote.back() }
} }
private fun updatePrevNextColor() { private fun updatePrevNextColor() {
nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) nextButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
@ -216,7 +237,6 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
}) })
} }
override fun onRepeatModeChanged() { override fun onRepeatModeChanged() {
updateRepeatState() updateRepeatState()
} }
@ -231,7 +251,10 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -306,5 +329,4 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
fun onFavoriteToggled() { fun onFavoriteToggled() {
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
} }

View file

@ -25,7 +25,10 @@ import code.name.monkey.retromusic.model.lyrics.Lyrics
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.fragment_full.* import kotlinx.android.synthetic.main.fragment_full.artistImage
import kotlinx.android.synthetic.main.fragment_full.nextSong
import kotlinx.android.synthetic.main.fragment_full.nextSongLabel
import kotlinx.android.synthetic.main.fragment_full.playerToolbar
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -63,7 +66,10 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
lyricsLine1.visibility = View.VISIBLE lyricsLine1.visibility = View.VISIBLE
lyricsLine2.visibility = View.VISIBLE lyricsLine2.visibility = View.VISIBLE
lyricsLine2.measure(View.MeasureSpec.makeMeasureSpec(lyricsLine2.measuredWidth, View.MeasureSpec.EXACTLY), View.MeasureSpec.UNSPECIFIED) lyricsLine2.measure(
View.MeasureSpec.makeMeasureSpec(lyricsLine2.measuredWidth, View.MeasureSpec.EXACTLY),
View.MeasureSpec.UNSPECIFIED
)
val h: Float = lyricsLine2.measuredHeight.toFloat() val h: Float = lyricsLine2.measuredHeight.toFloat()
lyricsLine1.alpha = 1f lyricsLine1.alpha = 1f
@ -125,8 +131,10 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
} }
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_full, container, false) return inflater.inflate(R.layout.fragment_full, container, false)
} }
@ -152,19 +160,19 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
fullPlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FullPlaybackControlsFragment fullPlaybackControlsFragment =
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FullPlaybackControlsFragment
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
playerAlbumCoverFragment.removeSlideEffect() playerAlbumCoverFragment.removeSlideEffect()
} }
override fun onShow() { override fun onShow() {
} }
override fun onHide() { override fun onHide() {
} }
override fun onBackPressed(): Boolean { override fun onBackPressed(): Boolean {
@ -219,13 +227,12 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
val artist = ArtistLoader.getArtist(requireContext(), MusicPlayerRemote.currentSong.artistId) val artist = ArtistLoader.getArtist(requireContext(), MusicPlayerRemote.currentSong.artistId)
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist) ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist)
.generatePalette(requireContext()) .generatePalette(requireContext())
.build() .build()
.into(object : RetroMusicColoredTarget(artistImage) { .into(object : RetroMusicColoredTarget(artistImage) {
override fun onColorReady(color: Int) { override fun onColorReady(color: Int) {
}
} })
})
} }
} }
} }

View file

@ -13,6 +13,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -23,7 +24,17 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_material_playback_controls.* import kotlinx.android.synthetic.main.fragment_material_playback_controls.nextButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.playPauseButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.previousButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.progressSlider
import kotlinx.android.synthetic.main.fragment_material_playback_controls.repeatButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.shuffleButton
import kotlinx.android.synthetic.main.fragment_material_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_material_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_material_playback_controls.songTotalTime
import kotlinx.android.synthetic.main.fragment_material_playback_controls.text
import kotlinx.android.synthetic.main.fragment_material_playback_controls.title
/** /**
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
@ -34,14 +45,15 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
private var lastDisabledPlaybackControlsColor: Int = 0 private var lastDisabledPlaybackControlsColor: Int = 0
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this) progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_material_playback_controls, container, false) return inflater.inflate(R.layout.fragment_material_playback_controls, container, false)
} }
@ -56,6 +68,12 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
} }
override fun onResume() { override fun onResume() {
@ -96,10 +114,12 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground) val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) { if (ColorUtil.isColorLight(colorBg)) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true) lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true) lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else { } else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false) lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) lastDisabledPlaybackControlsColor =
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
updateRepeatState() updateRepeatState()
@ -133,7 +153,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_64dp) playPauseButton.setImageResource(R.drawable.ic_pause_white_64dp)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_64dp); playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_64dp)
} }
} }
@ -162,7 +182,10 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -189,11 +212,9 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
} }
public override fun show() { public override fun show() {
} }
public override fun hide() { public override fun hide() {
} }
override fun setUpProgressSlider() { override fun setUpProgressSlider() {
@ -201,8 +222,10 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) { if (fromUser) {
MusicPlayerRemote.seekTo(progress) MusicPlayerRemote.seekTo(progress)
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis, onUpdateProgressViews(
MusicPlayerRemote.songDurationMillis) MusicPlayerRemote.songProgressMillis,
MusicPlayerRemote.songDurationMillis
)
} }
} }
}) })

View file

@ -13,12 +13,13 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import kotlinx.android.synthetic.main.fragment_material.* import kotlinx.android.synthetic.main.fragment_material.playerToolbar
/** /**
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
*/ */
class MaterialFragment : AbsPlayerFragment() { class MaterialFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }
@ -52,7 +53,11 @@ class MaterialFragment : AbsPlayerFragment() {
lastColor = color lastColor = color
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
requireActivity()
)
} }
override fun toggleFavorite(song: Song) { override fun toggleFavorite(song: Song) {
@ -66,8 +71,10 @@ class MaterialFragment : AbsPlayerFragment() {
toggleFavorite(MusicPlayerRemote.currentSong) toggleFavorite(MusicPlayerRemote.currentSong)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_material, container, false) return inflater.inflate(R.layout.fragment_material, container, false)
} }
@ -75,12 +82,13 @@ class MaterialFragment : AbsPlayerFragment() {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setUpSubFragments() setUpSubFragments()
setUpPlayerToolbar() setUpPlayerToolbar()
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as MaterialControlsFragment playbackControlsFragment =
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as MaterialControlsFragment
val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
} }
@ -89,7 +97,11 @@ class MaterialFragment : AbsPlayerFragment() {
inflateMenu(R.menu.menu_player) inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { requireActivity().onBackPressed() } setNavigationOnClickListener { requireActivity().onBackPressed() }
setOnMenuItemClickListener(this@MaterialFragment) setOnMenuItemClickListener(this@MaterialFragment)
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
this,
ATHUtil.resolveColor(context, R.attr.colorControlNormal),
requireActivity()
)
} }
} }

View file

@ -1,6 +1,8 @@
package code.name.monkey.retromusic.fragments.player.normal package code.name.monkey.retromusic.fragments.player.normal
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.graphics.PorterDuff import android.graphics.PorterDuff
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -15,6 +17,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -32,11 +35,12 @@ import kotlinx.android.synthetic.main.fragment_player_playback_controls.progress
import kotlinx.android.synthetic.main.fragment_player_playback_controls.repeatButton import kotlinx.android.synthetic.main.fragment_player_playback_controls.repeatButton
import kotlinx.android.synthetic.main.fragment_player_playback_controls.shuffleButton import kotlinx.android.synthetic.main.fragment_player_playback_controls.shuffleButton
import kotlinx.android.synthetic.main.fragment_player_playback_controls.songCurrentProgress import kotlinx.android.synthetic.main.fragment_player_playback_controls.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_player_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_player_playback_controls.songTotalTime import kotlinx.android.synthetic.main.fragment_player_playback_controls.songTotalTime
import kotlinx.android.synthetic.main.fragment_player_playback_controls.text import kotlinx.android.synthetic.main.fragment_player_playback_controls.text
import kotlinx.android.synthetic.main.fragment_player_playback_controls.title import kotlinx.android.synthetic.main.fragment_player_playback_controls.title
class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() { class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment(), OnSharedPreferenceChangeListener {
private var lastPlaybackControlsColor: Int = 0 private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0 private var lastDisabledPlaybackControlsColor: Int = 0
@ -51,7 +55,6 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View? {
return inflater.inflate(R.layout.fragment_player_playback_controls, container, false) return inflater.inflate(R.layout.fragment_player_playback_controls, container, false)
} }
@ -67,6 +70,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
showBonceAnimation(playPauseButton) showBonceAnimation(playPauseButton)
} }
title.isSelected = true title.isSelected = true
PreferenceUtil.getInstance(requireContext()).registerOnSharedPreferenceChangedListener(this)
} }
override fun setDark(color: Int) { override fun setDark(color: Int) {
@ -103,10 +107,16 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
updatePrevNextColor() updatePrevNextColor()
} }
private fun updateSong() { private fun updateSong() {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
} }
override fun onResume() { override fun onResume() {
@ -253,4 +263,16 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong()) songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong()) songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
} }
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
println(key)
if (key == PreferenceUtil.EXTRA_SONG_INFO) {
updateSong()
}
}
override fun onDestroyView() {
super.onDestroyView()
PreferenceUtil.getInstance(requireContext()).unregisterOnSharedPreferenceChangedListener(this)
}
} }

View file

@ -39,7 +39,14 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_peak_control_player.* import kotlinx.android.synthetic.main.fragment_peak_control_player.nextButton
import kotlinx.android.synthetic.main.fragment_peak_control_player.playPauseButton
import kotlinx.android.synthetic.main.fragment_peak_control_player.previousButton
import kotlinx.android.synthetic.main.fragment_peak_control_player.progressSlider
import kotlinx.android.synthetic.main.fragment_peak_control_player.repeatButton
import kotlinx.android.synthetic.main.fragment_peak_control_player.shuffleButton
import kotlinx.android.synthetic.main.fragment_peak_control_player.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_peak_control_player.songTotalTime
/** /**
* Created by hemanths on 2019-10-04. * Created by hemanths on 2019-10-04.
@ -67,37 +74,37 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
} }
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View? {
return inflater.inflate(R.layout.fragment_peak_control_player, container, false) return inflater.inflate(R.layout.fragment_peak_control_player, container, false)
} }
override fun onViewCreated( override fun onViewCreated(
view: View, view: View,
savedInstanceState: Bundle? savedInstanceState: Bundle?
) { ) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setUpMusicControllers() setUpMusicControllers()
} }
override fun show() { override fun show() {
} }
override fun hide() { override fun hide() {
} }
override fun setDark(color: Int) { override fun setDark(color: Int) {
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground) val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) { if (ColorUtil.isColorLight(colorBg)) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true) lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true) lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else { } else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false) lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) lastDisabledPlaybackControlsColor =
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
@ -185,15 +192,16 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {

View file

@ -22,13 +22,19 @@ import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.glide.SongGlideRequest import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_peak_player.* import kotlinx.android.synthetic.main.fragment_peak_player.playerImage
import kotlinx.android.synthetic.main.fragment_peak_player.playerToolbar
import kotlinx.android.synthetic.main.fragment_peak_player.songInfo
import kotlinx.android.synthetic.main.fragment_peak_player.text
import kotlinx.android.synthetic.main.fragment_peak_player.title
/** /**
* Created by hemanths on 2019-10-03. * Created by hemanths on 2019-10-03.
@ -54,7 +60,8 @@ class PeakPlayerFragment : AbsPlayerFragment() {
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PeakPlayerControlFragment playbackControlsFragment =
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PeakPlayerControlFragment
} }
private fun setUpPlayerToolbar() { private fun setUpPlayerToolbar() {
@ -62,7 +69,11 @@ class PeakPlayerFragment : AbsPlayerFragment() {
inflateMenu(R.menu.menu_player) inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { requireActivity().onBackPressed() } setNavigationOnClickListener { requireActivity().onBackPressed() }
setOnMenuItemClickListener(this@PeakPlayerFragment) setOnMenuItemClickListener(this@PeakPlayerFragment)
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
this,
ATHUtil.resolveColor(context, R.attr.colorControlNormal),
requireActivity()
)
} }
} }
@ -71,11 +82,9 @@ class PeakPlayerFragment : AbsPlayerFragment() {
} }
override fun onShow() { override fun onShow() {
} }
override fun onHide() { override fun onHide() {
} }
override fun onBackPressed(): Boolean { override fun onBackPressed(): Boolean {
@ -96,24 +105,27 @@ class PeakPlayerFragment : AbsPlayerFragment() {
} }
override fun onFavoriteToggled() { override fun onFavoriteToggled() {
} }
private fun updateSong() { private fun updateSong() {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong) SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext()) .checkIgnoreMediaStore(requireContext())
.generatePalette(requireContext()) .generatePalette(requireContext())
.build() .build()
.into(object : RetroMusicColoredTarget(playerImage) { .into(object : RetroMusicColoredTarget(playerImage) {
override fun onColorReady(color: Int) { override fun onColorReady(color: Int) {
playbackControlsFragment.setDark(color) playbackControlsFragment.setDark(color)
} }
}) })
} }
override fun onServiceConnected() { override fun onServiceConnected() {

View file

@ -16,6 +16,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -26,6 +27,7 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.songInfo
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.nextButton import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.nextButton
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.playPauseButton import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.playPauseButton
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.previousButton import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.previousButton
@ -61,6 +63,20 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
updatePlayPauseDrawableState() updatePlayPauseDrawableState()
updateRepeatState() updateRepeatState()
updateShuffleState() updateShuffleState()
updateSong()
}
override fun onPlayingMetaChanged() {
super.onPlayingMetaChanged()
updateSong()
}
private fun updateSong() {
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong)
} else {
songInfo?.hide()
}
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {

View file

@ -12,7 +12,9 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import kotlinx.android.synthetic.main.fragment_plain_player.* import kotlinx.android.synthetic.main.fragment_plain_player.playerToolbar
import kotlinx.android.synthetic.main.fragment_plain_player.text
import kotlinx.android.synthetic.main.fragment_plain_player.title
class PlainPlayerFragment : AbsPlayerFragment() { class PlainPlayerFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
@ -24,7 +26,6 @@ class PlainPlayerFragment : AbsPlayerFragment() {
override val paletteColor: Int override val paletteColor: Int
get() = lastColor get() = lastColor
override fun onPlayingMetaChanged() { override fun onPlayingMetaChanged() {
super.onPlayingMetaChanged() super.onPlayingMetaChanged()
updateSong() updateSong()
@ -41,8 +42,10 @@ class PlainPlayerFragment : AbsPlayerFragment() {
updateSong() updateSong()
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_plain_player, container, false) return inflater.inflate(R.layout.fragment_plain_player, container, false)
} }
@ -51,7 +54,11 @@ class PlainPlayerFragment : AbsPlayerFragment() {
inflateMenu(R.menu.menu_player) inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { requireActivity().onBackPressed() } setNavigationOnClickListener { requireActivity().onBackPressed() }
setOnMenuItemClickListener(this@PlainPlayerFragment) setOnMenuItemClickListener(this@PlainPlayerFragment)
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
this,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
requireActivity()
)
} }
} }
@ -64,8 +71,10 @@ class PlainPlayerFragment : AbsPlayerFragment() {
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
plainPlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlainPlaybackControlsFragment plainPlaybackControlsFragment =
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlainPlaybackControlsFragment
val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
} }
@ -90,7 +99,11 @@ class PlainPlayerFragment : AbsPlayerFragment() {
plainPlaybackControlsFragment.setDark(color) plainPlaybackControlsFragment.setDark(color)
lastColor = color lastColor = color
callbacks!!.onPaletteColorChanged() callbacks!!.onPaletteColorChanged()
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
requireActivity()
)
} }
override fun onFavoriteToggled() { override fun onFavoriteToggled() {

View file

@ -12,6 +12,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
@ -19,7 +20,15 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.* import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.nextButton
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.playPauseButton
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.previousButton
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.repeatButton
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.shuffleButton
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.songCurrentProgress
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.songInfo
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.text
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.title
/** /**
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
@ -31,7 +40,6 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
private var lastDisabledPlaybackControlsColor: Int = 0 private var lastDisabledPlaybackControlsColor: Int = 0
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
override fun onPlayStateChanged() { override fun onPlayStateChanged() {
updatePlayPauseDrawableState() updatePlayPauseDrawableState()
} }
@ -56,7 +64,6 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this) progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_simple_controls_fragment, container, false) return inflater.inflate(R.layout.fragment_simple_controls_fragment, container, false)
} }
@ -110,7 +117,10 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> shuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -140,21 +150,25 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
} }
override fun onPlayingMetaChanged() { override fun onPlayingMetaChanged() {
super.onPlayingMetaChanged() super.onPlayingMetaChanged()
updateSong() updateSong()
} }
public override fun show() { public override fun show() {
playPauseButton!!.animate() playPauseButton!!.animate()
.scaleX(1f) .scaleX(1f)
.scaleY(1f) .scaleY(1f)
.rotation(360f) .rotation(360f)
.setInterpolator(DecelerateInterpolator()) .setInterpolator(DecelerateInterpolator())
.start() .start()
} }
public override fun hide() { public override fun hide() {
@ -168,12 +182,14 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
override fun setUpProgressSlider() { override fun setUpProgressSlider() {
} }
override fun onUpdateProgressViews(progress: Int, total: Int) { override fun onUpdateProgressViews(progress: Int, total: Int) {
songCurrentProgress!!.text = String.format("%s / %s", MusicUtil.getReadableDurationString(progress.toLong()), MusicUtil.getReadableDurationString(total.toLong())) songCurrentProgress!!.text = String.format(
"%s / %s",
MusicUtil.getReadableDurationString(progress.toLong()),
MusicUtil.getReadableDurationString(total.toLong())
)
} }
override fun setDark(color: Int) { override fun setDark(color: Int) {
@ -194,7 +210,11 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
volumeFragment?.setTintable(colorFinal) volumeFragment?.setTintable(colorFinal)
TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(context!!, ColorUtil.isColorLight(colorFinal)), false) TintHelper.setTintAuto(
playPauseButton,
MaterialValueHelper.getPrimaryTextColor(context!!, ColorUtil.isColorLight(colorFinal)),
false
)
TintHelper.setTintAuto(playPauseButton, colorFinal, true) TintHelper.setTintAuto(playPauseButton, colorFinal, true)
text.setTextColor(colorFinal) text.setTextColor(colorFinal)

View file

@ -12,13 +12,14 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import kotlinx.android.synthetic.main.fragment_simple_player.* import kotlinx.android.synthetic.main.fragment_simple_player.playerToolbar
/** /**
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
*/ */
class SimplePlayerFragment : AbsPlayerFragment() { class SimplePlayerFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }
@ -29,8 +30,10 @@ class SimplePlayerFragment : AbsPlayerFragment() {
private lateinit var simplePlaybackControlsFragment: SimplePlaybackControlsFragment private lateinit var simplePlaybackControlsFragment: SimplePlaybackControlsFragment
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(
savedInstanceState: Bundle?): View? { inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_simple_player, container, false) return inflater.inflate(R.layout.fragment_simple_player, container, false)
} }
@ -42,9 +45,11 @@ class SimplePlayerFragment : AbsPlayerFragment() {
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
simplePlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as SimplePlaybackControlsFragment simplePlaybackControlsFragment =
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as SimplePlaybackControlsFragment
} }
override fun onShow() { override fun onShow() {
@ -67,7 +72,11 @@ class SimplePlayerFragment : AbsPlayerFragment() {
lastColor = color lastColor = color
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
simplePlaybackControlsFragment.setDark(color) simplePlaybackControlsFragment.setDark(color)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
requireActivity()
)
} }
override fun onFavoriteToggled() { override fun onFavoriteToggled() {
@ -85,6 +94,10 @@ class SimplePlayerFragment : AbsPlayerFragment() {
playerToolbar.inflateMenu(R.menu.menu_player) playerToolbar.inflateMenu(R.menu.menu_player)
playerToolbar.setNavigationOnClickListener { requireActivity().onBackPressed() } playerToolbar.setNavigationOnClickListener { requireActivity().onBackPressed() }
playerToolbar.setOnMenuItemClickListener(this) playerToolbar.setOnMenuItemClickListener(this)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity()) ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(context, R.attr.colorControlNormal),
requireActivity()
)
} }
} }

View file

@ -11,45 +11,44 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.* import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.playerRepeatButton
import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.playerShuffleButton
class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() { class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun show() { override fun show() {
} }
override fun hide() { override fun hide() {
} }
override fun setUpProgressSlider() { override fun setUpProgressSlider() {
} }
override fun setDark(color: Int) { override fun setDark(color: Int) {
if (ColorUtil.isColorLight(color)) { if (ColorUtil.isColorLight(color)) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true) lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true) lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else { } else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false) lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) lastDisabledPlaybackControlsColor =
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
updateRepeatState(); updateRepeatState()
updateShuffleState(); updateShuffleState()
} }
override fun onUpdateProgressViews(progress: Int, total: Int) { override fun onUpdateProgressViews(progress: Int, total: Int) {
} }
private var lastPlaybackControlsColor: Int = 0 private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0 private var lastDisabledPlaybackControlsColor: Int = 0
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_tiny_controls_fragment, container, false); return inflater.inflate(R.layout.fragment_tiny_controls_fragment, container, false)
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -73,7 +72,10 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateShuffleState() { override fun updateShuffleState() {
when (MusicPlayerRemote.shuffleMode) { when (MusicPlayerRemote.shuffleMode) {
MusicService.SHUFFLE_MODE_SHUFFLE -> playerShuffleButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN) MusicService.SHUFFLE_MODE_SHUFFLE -> playerShuffleButton.setColorFilter(
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
else -> playerShuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN) else -> playerShuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -107,4 +109,5 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun onShuffleModeChanged() { override fun onShuffleModeChanged() {
updateShuffleState() updateShuffleState()
} }
} }

View file

@ -13,6 +13,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.fragments.MiniPlayerFragment import code.name.monkey.retromusic.fragments.MiniPlayerFragment
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
@ -23,7 +24,12 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_tiny_player.* import kotlinx.android.synthetic.main.fragment_tiny_player.playerSongTotalTime
import kotlinx.android.synthetic.main.fragment_tiny_player.playerToolbar
import kotlinx.android.synthetic.main.fragment_tiny_player.progressBar
import kotlinx.android.synthetic.main.fragment_tiny_player.songInfo
import kotlinx.android.synthetic.main.fragment_tiny_player.text
import kotlinx.android.synthetic.main.fragment_tiny_player.title
class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback { class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
override fun onUpdateProgressViews(progress: Int, total: Int) { override fun onUpdateProgressViews(progress: Int, total: Int) {
@ -38,17 +44,17 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
animatorSet.interpolator = LinearInterpolator() animatorSet.interpolator = LinearInterpolator()
animatorSet.start() animatorSet.start()
playerSongTotalTime.text = String.format("%s/%s", MusicUtil.getReadableDurationString(total.toLong()), playerSongTotalTime.text = String.format(
MusicUtil.getReadableDurationString(progress.toLong())) "%s/%s", MusicUtil.getReadableDurationString(total.toLong()),
MusicUtil.getReadableDurationString(progress.toLong())
)
} }
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }
override fun onShow() { override fun onShow() {
} }
override fun onHide() { override fun onHide() {
@ -95,7 +101,7 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
title.setTextColor(textColorPrimary) title.setTextColor(textColorPrimary)
text.setTextColor(textColorPrimaryDisabled) text.setTextColor(textColorPrimaryDisabled)
songInfo.setTextColor(textColorPrimaryDisabled)
playerSongTotalTime.setTextColor(textColorPrimary) playerSongTotalTime.setTextColor(textColorPrimary)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, textColorPrimary, requireActivity()) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, textColorPrimary, requireActivity())
@ -127,6 +133,12 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = String.format("%s \nby - %s", song.albumName, song.artistName) text.text = String.format("%s \nby - %s", song.albumName, song.artistName)
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
songInfo?.text = getSongInfo(song)
} else {
songInfo?.hide()
}
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@ -144,10 +156,11 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
} }
private fun setUpSubFragments() { private fun setUpSubFragments() {
tinyPlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as TinyPlaybackControlsFragment tinyPlaybackControlsFragment =
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as TinyPlaybackControlsFragment
val playerAlbumCoverFragment =
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this) playerAlbumCoverFragment.setCallbacks(this)
} }
private fun setUpPlayerToolbar() { private fun setUpPlayerToolbar() {
@ -174,5 +187,4 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
super.onPlayingMetaChanged() super.onPlayingMetaChanged()
updateSong() updateSong()
} }
} }

View file

@ -18,6 +18,7 @@ import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
@ -57,7 +58,7 @@ public final class PreferenceUtil {
public static final String LIBRARY_CATEGORIES = "library_categories"; public static final String LIBRARY_CATEGORIES = "library_categories";
public static final String HIDE_HOME_BANNER_SEARCH = "hide_home_banner_search"; public static final String EXTRA_SONG_INFO = "extra_song_info";
public static final String DESATURATED_COLOR = "desaturated_color"; public static final String DESATURATED_COLOR = "desaturated_color";
@ -698,8 +699,8 @@ public final class PreferenceUtil {
return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false); return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false);
} }
public boolean getBannerSearchEnable() { public boolean isSongInfo() {
return mPreferences.getBoolean(HIDE_HOME_BANNER_SEARCH, false); return mPreferences.getBoolean(EXTRA_SONG_INFO, false);
} }
public void setSleepTimerFinishMusic(final boolean value) { public void setSleepTimerFinishMusic(final boolean value) {
@ -992,7 +993,7 @@ public final class PreferenceUtil {
} }
public void unregisterOnSharedPreferenceChangedListener( public void unregisterOnSharedPreferenceChangedListener(
SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener) { @NonNull OnSharedPreferenceChangeListener sharedPreferenceChangeListener) {
mPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); mPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
} }
} }

View file

@ -16,7 +16,6 @@ package code.name.monkey.retromusic.util;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
@ -36,21 +35,19 @@ import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat; import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
import code.name.monkey.appthemehelper.util.TintHelper; import code.name.monkey.appthemehelper.util.TintHelper;
import code.name.monkey.retromusic.App; import code.name.monkey.retromusic.App;
public class RetroUtil { public class RetroUtil {
private static final int[] TEMP_ARRAY = new int[1]; private static final int[] TEMP_ARRAY = new int[1];
private static final String SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar";
private static final String SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar";
public static int calculateNoOfColumns(@NonNull Context context) { public static int calculateNoOfColumns(@NonNull Context context) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
@ -58,25 +55,18 @@ public class RetroUtil {
return (int) (dpWidth / 180); return (int) (dpWidth / 180);
} }
public static boolean isTablet() { @NonNull
return App.Companion.getContext().getResources().getConfiguration().smallestScreenWidthDp >= 600; public static Bitmap createBitmap(@NonNull Drawable drawable, float sizeMultiplier) {
Bitmap bitmap = Bitmap.createBitmap((int) (drawable.getIntrinsicWidth() * sizeMultiplier),
(int) (drawable.getIntrinsicHeight() * sizeMultiplier), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
drawable.setBounds(0, 0, c.getWidth(), c.getHeight());
drawable.draw(c);
return bitmap;
} }
public static boolean isLandscape() { public static float frequencyCount(int frequency) {
return App.Companion.getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; return (float) (frequency / 1000.0);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isRTL(@NonNull Context context) {
Configuration config = context.getResources().getConfiguration();
return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
public static void openUrl(@NonNull Activity context, @NonNull String str) {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse(str));
intent.setFlags(268435456);
context.startActivity(intent);
} }
public static Point getScreenSize(@NonNull Context c) { public static Point getScreenSize(@NonNull Context c) {
@ -91,6 +81,38 @@ public class RetroUtil {
return size; return size;
} }
public static int getStatusBarHeight() {
int result = 0;
int resourceId = App.Companion.getContext().getResources()
.getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = App.Companion.getContext().getResources().getDimensionPixelSize(resourceId);
}
return result;
}
@Nullable
public static Drawable getTintedVectorDrawable(@NonNull Context context, @DrawableRes int id,
@ColorInt int color) {
return TintHelper.createTintedDrawable(
getVectorDrawable(context.getResources(), id, context.getTheme()), color);
}
@Nullable
public static Drawable getTintedVectorDrawable(@NonNull Resources res, @DrawableRes int resId,
@Nullable Resources.Theme theme, @ColorInt int color) {
return TintHelper.createTintedDrawable(getVectorDrawable(res, resId, theme), color);
}
@Nullable
public static Drawable getVectorDrawable(@NonNull Resources res, @DrawableRes int resId,
@Nullable Resources.Theme theme) {
if (Build.VERSION.SDK_INT >= 21) {
return res.getDrawable(resId, theme);
}
return VectorDrawableCompat.create(res, resId, theme);
}
public static void hideSoftKeyboard(@Nullable Activity activity) { public static void hideSoftKeyboard(@Nullable Activity activity) {
if (activity != null) { if (activity != null) {
View currentFocus = activity.getCurrentFocus(); View currentFocus = activity.getCurrentFocus();
@ -104,38 +126,6 @@ public class RetroUtil {
} }
} }
@Nullable
public static Drawable getVectorDrawable(@NonNull Resources res, @DrawableRes int resId,
@Nullable Resources.Theme theme) {
if (Build.VERSION.SDK_INT >= 21) {
return res.getDrawable(resId, theme);
}
return VectorDrawableCompat.create(res, resId, theme);
}
@Nullable
public static Drawable getTintedVectorDrawable(@NonNull Context context, @DrawableRes int id,
@ColorInt int color) {
return TintHelper.createTintedDrawable(
getVectorDrawable(context.getResources(), id, context.getTheme()), color);
}
@NonNull
public static Bitmap createBitmap(@NonNull Drawable drawable, float sizeMultiplier) {
Bitmap bitmap = Bitmap.createBitmap((int) (drawable.getIntrinsicWidth() * sizeMultiplier),
(int) (drawable.getIntrinsicHeight() * sizeMultiplier), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
drawable.setBounds(0, 0, c.getWidth(), c.getHeight());
drawable.draw(c);
return bitmap;
}
@Nullable
public static Drawable getTintedVectorDrawable(@NonNull Resources res, @DrawableRes int resId,
@Nullable Resources.Theme theme, @ColorInt int color) {
return TintHelper.createTintedDrawable(getVectorDrawable(res, resId, theme), color);
}
public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) { public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) {
switch (PreferenceUtil.getInstance(context).autoDownloadImagesPolicy()) { switch (PreferenceUtil.getInstance(context).autoDownloadImagesPolicy()) {
case "always": case "always":
@ -152,13 +142,26 @@ public class RetroUtil {
} }
} }
public static int getStatusBarHeight() { public static boolean isLandscape() {
int result = 0; return App.Companion.getContext().getResources().getConfiguration().orientation
int resourceId = App.Companion.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android"); == Configuration.ORIENTATION_LANDSCAPE;
if (resourceId > 0) { }
result = App.Companion.getContext().getResources().getDimensionPixelSize(resourceId);
} @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
return result; public static boolean isRTL(@NonNull Context context) {
Configuration config = context.getResources().getConfiguration();
return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
public static boolean isTablet() {
return App.Companion.getContext().getResources().getConfiguration().smallestScreenWidthDp >= 600;
}
public static void openUrl(@NonNull Activity context, @NonNull String str) {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse(str));
intent.setFlags(268435456);
context.startActivity(intent);
} }
public static void setAllowDrawUnderNavigationBar(Window window) { public static void setAllowDrawUnderNavigationBar(Window window) {

View file

@ -43,13 +43,30 @@
android:paddingEnd="24dp" android:paddingEnd="24dp"
android:textAppearance="@style/TextViewHeadline5" android:textAppearance="@style/TextViewHeadline5"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toTopOf="@+id/playPauseButton" app:layout_constraintBottom_toTopOf="@+id/songInfo"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title" app:layout_constraintTop_toBottomOf="@+id/title"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="?android:attr/textColorSecondary"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem/random"
tools:visibility="visible" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/previousButton" android:id="@+id/previousButton"
android:layout_width="72dp" android:layout_width="72dp"
@ -78,7 +95,7 @@
android:padding="12dp" android:padding="12dp"
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer" app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
app:layout_constraintStart_toEndOf="@id/previousButton" app:layout_constraintStart_toEndOf="@id/previousButton"
app:layout_constraintTop_toBottomOf="@+id/text" app:layout_constraintTop_toBottomOf="@+id/songInfo"
app:srcCompat="@drawable/ic_play_arrow_white_32dp" app:srcCompat="@drawable/ic_play_arrow_white_32dp"
tools:tint="@color/md_black_1000" /> tools:tint="@color/md_black_1000" />

View file

@ -108,5 +108,4 @@
tools:layout="@layout/fragment_adaptive_player_playback_controls" /> tools:layout="@layout/fragment_adaptive_player_playback_controls" />
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -152,4 +152,19 @@
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingEnd="8dp" /> android:paddingEnd="8dp" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem/random" />
</LinearLayout> </LinearLayout>

View file

@ -13,211 +13,212 @@
--> -->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/playback_controls" android:id="@+id/playback_controls"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="vertical" android:orientation="vertical"
tools:ignore="MissingPrefix"> tools:ignore="MissingPrefix">
<RelativeLayout <RelativeLayout
android:id="@+id/progressContainer" android:id="@+id/progressContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="28dp" android:layout_height="28dp"
android:paddingStart="12dp" android:paddingStart="12dp"
android:paddingEnd="12dp" android:paddingEnd="12dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatSeekBar <androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/progressSlider" android:id="@+id/progressSlider"
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal" style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:layout_toLeftOf="@id/songTotalTime" android:layout_toLeftOf="@id/songTotalTime"
android:layout_toRightOf="@id/songCurrentProgress" android:layout_toRightOf="@id/songCurrentProgress"
android:maxHeight="1.5dp" android:maxHeight="1.5dp"
android:progressDrawable="@drawable/color_progress_seek" android:progressDrawable="@drawable/color_progress_seek"
android:splitTrack="false" android:splitTrack="false"
tools:ignore="RtlHardcoded,UnusedAttribute" tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20" /> tools:progress="20" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/songTotalTime" android:id="@+id/songTotalTime"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:gravity="center_vertical|right|end" android:gravity="center_vertical|right|end"
android:paddingRight="8dp" android:paddingRight="8dp"
android:singleLine="true" android:singleLine="true"
android:textColor="?colorOnSecondary" android:textColor="?colorOnSecondary"
android:textSize="12sp" android:textSize="12sp"
tools:ignore="RtlHardcoded,RtlSymmetry" tools:ignore="RtlHardcoded,RtlSymmetry"
tools:text="00:22" /> tools:text="00:22" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/songCurrentProgress" android:id="@+id/songCurrentProgress"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:gravity="center_vertical|left|end" android:gravity="center_vertical|left|end"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:singleLine="true" android:singleLine="true"
android:textColor="?colorOnSecondary" android:textColor="?colorOnSecondary"
android:textSize="12sp" android:textSize="12sp"
tools:ignore="RtlHardcoded,RtlSymmetry" tools:ignore="RtlHardcoded,RtlSymmetry"
tools:text="00:22" /> tools:text="00:22" />
</RelativeLayout> </RelativeLayout>
<LinearLayout <LinearLayout
android:id="@+id/titleContainer" android:id="@+id/titleContainer"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/text" app:layout_constraintBottom_toTopOf="@+id/text"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressContainer"> app:layout_constraintTop_toBottomOf="@+id/progressContainer">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:ellipsize="marquee" android:ellipsize="marquee"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:freezesText="true" android:freezesText="true"
android:gravity="center" android:gravity="center"
android:marqueeRepeatLimit="marquee_forever" android:marqueeRepeatLimit="marquee_forever"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:scrollHorizontally="true" android:scrollHorizontally="true"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/TextViewHeadline6" android:textAppearance="@style/TextViewHeadline6"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold" android:textStyle="bold"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
</LinearLayout> </LinearLayout>
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/text" android:id="@+id/text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center" android:gravity="center"
android:maxLines="2" android:maxLines="2"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:textAppearance="@style/TextViewBody2" android:textAppearance="@style/TextViewBody1"
app:layout_constraintBottom_toTopOf="@+id/playerMediaControllerContainer" android:textColor="?android:attr/textColorSecondary"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toTopOf="@+id/songInfo"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintTop_toBottomOf="@+id/titleContainer"
app:layout_constraintStart_toStartOf="parent" tools:text="@tools:sample/lorem/random" />
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
tools:text="@tools:sample/lorem/random" />
<RelativeLayout <com.google.android.material.textview.MaterialTextView
android:id="@+id/playerMediaControllerContainer" android:id="@+id/songInfo"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layoutDirection="ltr" android:layout_gravity="center"
android:paddingStart="4dp" android:ellipsize="end"
android:paddingEnd="4dp" android:gravity="center"
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer" android:maxLines="2"
app:layout_constraintEnd_toEndOf="parent" android:paddingStart="16dp"
app:layout_constraintHorizontal_bias="0.5" android:paddingEnd="16dp"
app:layout_constraintStart_toStartOf="parent" android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@+id/text" android:textSize="12sp"
tools:ignore="ContentDescription,UnusedAttribute" app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
tools:showIn="@layout/fragment_player_playback_controls"> app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem/random" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/previousButton" android:id="@+id/repeatButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:background="?attr/roundSelector"
android:layout_marginEnd="8dp" android:padding="16dp"
android:layout_toStartOf="@+id/dummy_fab" android:scaleType="fitCenter"
android:background="?attr/roundSelector" app:layout_constraintBottom_toBottomOf="@+id/previousButton"
android:padding="16dp" app:layout_constraintEnd_toStartOf="@+id/previousButton"
android:scaleType="fitCenter" app:layout_constraintHorizontal_bias="0.5"
app:srcCompat="@drawable/ic_skip_previous_white_24dp" app:layout_constraintStart_toStartOf="parent"
tools:ignore="MissingPrefix" app:layout_constraintTop_toTopOf="@+id/previousButton"
tools:tint="@color/md_black_1000" /> app:srcCompat="@drawable/ic_repeat_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/nextButton" android:id="@+id/previousButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:background="?attr/roundSelector"
android:layout_marginStart="8dp" android:padding="16dp"
android:layout_toEndOf="@+id/dummy_fab" android:scaleType="fitCenter"
android:background="?attr/roundSelector" app:layout_constraintBottom_toBottomOf="@+id/playPauseButton"
android:padding="16dp" app:layout_constraintEnd_toStartOf="@+id/playPauseButton"
android:scaleType="fitCenter" app:layout_constraintStart_toEndOf="@+id/repeatButton"
app:srcCompat="@drawable/ic_skip_next_white_24dp" app:layout_constraintTop_toTopOf="@+id/playPauseButton"
tools:ignore="MissingPrefix" app:srcCompat="@drawable/ic_skip_previous_white_24dp"
tools:tint="@color/md_black_1000" /> tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/repeatButton" android:id="@+id/playPauseButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true" android:background="?attr/roundSelector"
android:layout_centerVertical="true" app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
android:background="?attr/roundSelector" app:layout_constraintEnd_toStartOf="@+id/nextButton"
android:padding="16dp" app:layout_constraintHorizontal_bias="0.5"
android:scaleType="fitCenter" app:layout_constraintStart_toEndOf="@+id/previousButton"
app:srcCompat="@drawable/ic_repeat_white_24dp" app:layout_constraintTop_toBottomOf="@+id/songInfo"
tools:ignore="MissingPrefix" app:srcCompat="@drawable/ic_pause_white_64dp"
tools:tint="@color/md_black_1000" /> tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/shuffleButton" android:id="@+id/nextButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:background="?attr/roundSelector"
android:layout_centerVertical="true" android:padding="16dp"
android:background="?attr/roundSelector" android:scaleType="fitCenter"
android:padding="16dp" app:layout_constraintBottom_toBottomOf="@+id/playPauseButton"
android:scaleType="fitCenter" app:layout_constraintEnd_toStartOf="@+id/shuffleButton"
app:srcCompat="@drawable/ic_shuffle_white_24dp" app:layout_constraintStart_toEndOf="@+id/playPauseButton"
tools:ignore="MissingPrefix" app:layout_constraintTop_toTopOf="@+id/playPauseButton"
tools:tint="@color/md_black_1000" /> app:srcCompat="@drawable/ic_skip_next_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<Space <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/dummy_fab" android:id="@+id/shuffleButton"
android:layout_width="56dp" android:layout_width="wrap_content"
android:layout_height="56dp" android:layout_height="wrap_content"
android:layout_centerInParent="true" /> android:background="?attr/roundSelector"
android:padding="16dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/nextButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/nextButton"
app:layout_constraintTop_toTopOf="@+id/nextButton"
app:srcCompat="@drawable/ic_shuffle_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <FrameLayout
android:id="@+id/playPauseButton" android:id="@+id/volumeFragmentContainer"
android:layout_width="52dp" android:layout_width="match_parent"
android:layout_height="52dp" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_weight="0"
android:background="@drawable/color_circle_gradient" android:paddingStart="8dp"
android:elevation="4dp" android:paddingEnd="8dp"
android:padding="16dp" app:layout_constraintBottom_toBottomOf="parent"
app:srcCompat="@drawable/ic_play_arrow_white_32dp" /> tools:backgroundTint="@color/md_red_400"
tools:layout_height="52dp" />
</RelativeLayout>
<FrameLayout
android:id="@+id/volumeFragmentContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingStart="8dp"
android:paddingEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
tools:backgroundTint="@color/md_red_400"
tools:layout_height="52dp" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -71,5 +71,19 @@
android:thumbTint="@color/md_white_1000" android:thumbTint="@color/md_white_1000"
tools:progress="20" /> tools:progress="20" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingEnd="16dp"
android:textSize="12sp"
tools:text="@tools:sample/lorem/random" />
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -1,122 +1,133 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/playback_controls" android:id="@+id/playback_controls"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:orientation="vertical" android:orientation="vertical"
tools:ignore="MissingPrefix"> tools:ignore="MissingPrefix">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/progress_container_height" android:layout_height="@dimen/progress_container_height"
android:background="@color/twenty_percent_black_overlay"> android:background="@color/twenty_percent_black_overlay">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/songCurrentProgress" android:id="@+id/songCurrentProgress"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:gravity="center_vertical|left|end" android:gravity="center_vertical|left|end"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:singleLine="true" android:singleLine="true"
android:textColor="?colorOnSecondary" android:textColor="?colorOnSecondary"
android:textSize="12sp" android:textSize="12sp"
tools:ignore="RtlHardcoded,RtlSymmetry" /> tools:ignore="RtlHardcoded,RtlSymmetry" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/songTotalTime" android:id="@+id/songTotalTime"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:gravity="center_vertical|right|end" android:gravity="center_vertical|right|end"
android:paddingRight="8dp" android:paddingRight="8dp"
android:singleLine="true" android:singleLine="true"
android:textColor="?colorOnSecondary" android:textColor="?colorOnSecondary"
android:textSize="12sp" android:textSize="12sp"
tools:ignore="RtlHardcoded,RtlSymmetry" /> tools:ignore="RtlHardcoded,RtlSymmetry" />
<androidx.appcompat.widget.AppCompatSeekBar <androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/progressSlider" android:id="@+id/progressSlider"
style="@style/MusicProgressSlider" style="@style/MusicProgressSlider"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_toLeftOf="@id/songTotalTime" android:layout_toLeftOf="@id/songTotalTime"
android:layout_toRightOf="@id/songCurrentProgress" android:layout_toRightOf="@id/songCurrentProgress"
tools:ignore="RtlHardcoded,UnusedAttribute" /> tools:ignore="RtlHardcoded,UnusedAttribute" />
</RelativeLayout> </RelativeLayout>
<include layout="@layout/media_button" /> <include layout="@layout/media_button" />
<FrameLayout <FrameLayout
android:id="@+id/volumeFragmentContainer" android:id="@+id/volumeFragmentContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingEnd="8dp" /> android:paddingEnd="8dp" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:foreground="?rectSelector" android:foreground="?rectSelector"
android:minHeight="72dp" android:minHeight="72dp"
android:orientation="horizontal" android:orientation="horizontal"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image" android:id="@+id/image"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:padding="16dp" android:padding="16dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
app:srcCompat="@drawable/ic_play_circle_filled_white_24dp" app:srcCompat="@drawable/ic_play_circle_filled_white_24dp"
app:tint="?colorAccent" /> app:tint="?colorAccent" />
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginBottom="12dp" android:layout_marginBottom="12dp"
android:layout_weight="1.0" android:layout_weight="1.0"
android:orientation="vertical" android:orientation="vertical"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="16dp"> android:paddingEnd="16dp">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="marquee" android:ellipsize="marquee"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:freezesText="true" android:freezesText="true"
android:marqueeRepeatLimit="marquee_forever" android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true" android:scrollHorizontally="true"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/TextViewHeadline6" android:textAppearance="@style/TextViewHeadline6"
android:textStyle="bold" android:textStyle="bold"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/text" android:id="@+id/text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="marquee" android:ellipsize="marquee"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:freezesText="true" android:freezesText="true"
android:marqueeRepeatLimit="marquee_forever" android:marqueeRepeatLimit="marquee_forever"
android:maxLines="2" android:maxLines="2"
android:scrollHorizontally="true" android:scrollHorizontally="true"
android:textStyle="bold" android:textStyle="bold"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
</LinearLayout>
</LinearLayout> <com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:paddingTop="4dp"
android:textSize="12sp"
tools:text="@tools:sample/lorem/random" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -91,7 +91,6 @@
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
</LinearLayout> </LinearLayout>
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/text" android:id="@+id/text"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -102,101 +101,101 @@
android:maxLines="2" android:maxLines="2"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:textAppearance="@style/TextViewBody2" android:textAppearance="@style/TextViewBody1"
app:layout_constraintBottom_toTopOf="@+id/playerMediaControllerContainer" android:textColor="?android:attr/textColorSecondary"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toTopOf="@+id/songInfo"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleContainer" app:layout_constraintTop_toBottomOf="@+id/titleContainer"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
<com.google.android.material.textview.MaterialTextView
<RelativeLayout android:id="@+id/songInfo"
android:id="@+id/playerMediaControllerContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layoutDirection="ltr" android:layout_gravity="center"
android:paddingStart="4dp" android:ellipsize="end"
android:paddingEnd="4dp" android:gravity="center"
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer" android:maxLines="2"
app:layout_constraintEnd_toEndOf="parent" android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem/random" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/repeatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/roundSelector"
android:padding="16dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/previousButton"
app:layout_constraintEnd_toStartOf="@+id/previousButton"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text" app:layout_constraintTop_toTopOf="@+id/previousButton"
tools:ignore="ContentDescription,UnusedAttribute" app:srcCompat="@drawable/ic_repeat_white_24dp"
tools:showIn="@layout/fragment_player_playback_controls"> tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/previousButton" android:id="@+id/previousButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:background="?attr/roundSelector"
android:layout_marginEnd="8dp" android:padding="16dp"
android:layout_toStartOf="@+id/dummy_fab" android:scaleType="fitCenter"
android:background="?attr/roundSelector" app:layout_constraintBottom_toBottomOf="@+id/playPauseButton"
android:padding="16dp" app:layout_constraintEnd_toStartOf="@+id/playPauseButton"
android:scaleType="fitCenter" app:layout_constraintStart_toEndOf="@+id/repeatButton"
app:srcCompat="@drawable/ic_skip_previous_white_24dp" app:layout_constraintTop_toTopOf="@+id/playPauseButton"
tools:ignore="MissingPrefix" app:srcCompat="@drawable/ic_skip_previous_white_24dp"
tools:tint="@color/md_black_1000" /> tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/nextButton" android:id="@+id/playPauseButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:background="?attr/roundSelector"
android:layout_marginStart="8dp" app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
android:layout_toEndOf="@+id/dummy_fab" app:layout_constraintEnd_toStartOf="@+id/nextButton"
android:background="?attr/roundSelector" app:layout_constraintHorizontal_bias="0.5"
android:padding="16dp" app:layout_constraintStart_toEndOf="@+id/previousButton"
android:scaleType="fitCenter" app:layout_constraintTop_toBottomOf="@+id/songInfo"
app:srcCompat="@drawable/ic_skip_next_white_24dp" app:srcCompat="@drawable/ic_pause_white_64dp"
tools:ignore="MissingPrefix" tools:tint="@color/md_black_1000" />
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/repeatButton" android:id="@+id/nextButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true" android:background="?attr/roundSelector"
android:layout_centerVertical="true" android:padding="16dp"
android:background="?attr/roundSelector" android:scaleType="fitCenter"
android:padding="16dp" app:layout_constraintBottom_toBottomOf="@+id/playPauseButton"
android:scaleType="fitCenter" app:layout_constraintEnd_toStartOf="@+id/shuffleButton"
app:srcCompat="@drawable/ic_repeat_white_24dp" app:layout_constraintStart_toEndOf="@+id/playPauseButton"
tools:ignore="MissingPrefix" app:layout_constraintTop_toTopOf="@+id/playPauseButton"
tools:tint="@color/md_black_1000" /> app:srcCompat="@drawable/ic_skip_next_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/shuffleButton" android:id="@+id/shuffleButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:background="?attr/roundSelector"
android:layout_centerVertical="true" android:padding="16dp"
android:background="?attr/roundSelector" android:scaleType="fitCenter"
android:padding="16dp" app:layout_constraintBottom_toBottomOf="@+id/nextButton"
android:scaleType="fitCenter" app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_shuffle_white_24dp" app:layout_constraintStart_toEndOf="@+id/nextButton"
tools:ignore="MissingPrefix" app:layout_constraintTop_toTopOf="@+id/nextButton"
tools:tint="@color/md_black_1000" /> app:srcCompat="@drawable/ic_shuffle_white_24dp"
tools:ignore="MissingPrefix"
<Space tools:tint="@color/md_black_1000" />
android:id="@+id/dummy_fab"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_centerInParent="true" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/playPauseButton"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_centerInParent="true"
android:background="@drawable/color_circle_gradient"
android:elevation="4dp"
android:padding="16dp"
app:srcCompat="@drawable/ic_play_arrow_white_32dp" />
</RelativeLayout>
<FrameLayout <FrameLayout
android:id="@+id/volumeFragmentContainer" android:id="@+id/volumeFragmentContainer"

View file

@ -1,103 +1,211 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/playback_controls" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:id="@+id/playback_controls"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:gravity="center_vertical" android:layout_height="wrap_content"
android:orientation="vertical" android:gravity="center_vertical"
tools:ignore="MissingPrefix"> android:orientation="vertical"
tools:ignore="MissingPrefix">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:id="@+id/progressContainer"
android:layout_height="@dimen/progress_container_height" android:layout_width="match_parent"
android:background="@color/twenty_percent_black_overlay"> android:layout_height="@dimen/progress_container_height"
android:background="@color/twenty_percent_black_overlay"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/songCurrentProgress" android:id="@+id/songCurrentProgress"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:gravity="center_vertical|left|end" android:gravity="center_vertical|left|end"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:singleLine="true" android:singleLine="true"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" android:textSize="12sp"
tools:ignore="RtlHardcoded,RtlSymmetry" tools:ignore="RtlHardcoded,RtlSymmetry"
tools:text="00:22" /> tools:text="00:22" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/songTotalTime" android:id="@+id/songTotalTime"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:gravity="center_vertical|right|end" android:gravity="center_vertical|right|end"
android:paddingRight="8dp" android:paddingRight="8dp"
android:singleLine="true" android:singleLine="true"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" android:textSize="12sp"
tools:ignore="RtlHardcoded,RtlSymmetry" tools:ignore="RtlHardcoded,RtlSymmetry"
tools:text="00:22" /> tools:text="00:22" />
<androidx.appcompat.widget.AppCompatSeekBar <androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/progressSlider" android:id="@+id/progressSlider"
style="@style/MusicProgressSlider" style="@style/MusicProgressSlider"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_toLeftOf="@id/songTotalTime" android:layout_toLeftOf="@id/songTotalTime"
android:layout_toRightOf="@id/songCurrentProgress" android:layout_toRightOf="@id/songCurrentProgress"
tools:ignore="RtlHardcoded,UnusedAttribute" /> tools:ignore="RtlHardcoded,UnusedAttribute" />
</RelativeLayout> </RelativeLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:id="@+id/titleContainer"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_weight="0" android:layout_height="wrap_content"
android:gravity="center" android:layout_marginTop="8dp"
android:orientation="vertical" android:layout_marginBottom="8dp"
android:padding="8dp"> app:layout_constraintBottom_toTopOf="@+id/text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressContainer">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:ellipsize="marquee" android:ellipsize="marquee"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:freezesText="true" android:freezesText="true"
android:gravity="center" android:gravity="center"
android:marqueeRepeatLimit="marquee_forever" android:marqueeRepeatLimit="marquee_forever"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:scrollHorizontally="true" android:scrollHorizontally="true"
android:singleLine="true" android:singleLine="true"
android:textAppearance="@style/TextViewHeadline6" android:textAppearance="@style/TextViewHeadline6"
android:textStyle="bold" android:textStyle="bold"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
</LinearLayout>
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/text" android:id="@+id/text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:ellipsize="end" android:layout_marginBottom="8dp"
android:gravity="center" android:ellipsize="end"
android:maxLines="2" android:gravity="center"
android:paddingStart="16dp" android:maxLines="2"
android:paddingTop="8dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingTop="8dp"
android:textAppearance="@style/TextViewBody2" android:paddingEnd="16dp"
tools:text="@tools:sample/lorem/random" /> android:textAppearance="@style/TextViewBody1"
</LinearLayout> android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toTopOf="@+id/songInfo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
tools:text="@tools:sample/lorem/random" />
<include layout="@layout/media_button" /> <com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem/random" />
<FrameLayout <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/volumeFragmentContainer" android:id="@+id/repeatButton"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:background="?attr/roundSelector"
android:paddingStart="8dp" android:padding="16dp"
android:paddingEnd="8dp" /> android:scaleType="fitCenter"
</LinearLayout> app:layout_constraintBottom_toBottomOf="@+id/previousButton"
app:layout_constraintEnd_toStartOf="@+id/previousButton"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/previousButton"
app:srcCompat="@drawable/ic_repeat_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/previousButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/roundSelector"
android:padding="16dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/playPauseButton"
app:layout_constraintEnd_toStartOf="@+id/playPauseButton"
app:layout_constraintStart_toEndOf="@+id/repeatButton"
app:layout_constraintTop_toTopOf="@+id/playPauseButton"
app:srcCompat="@drawable/ic_skip_previous_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/playPauseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="?attr/roundSelector"
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
app:layout_constraintEnd_toStartOf="@+id/nextButton"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/previousButton"
app:layout_constraintTop_toBottomOf="@+id/songInfo"
app:srcCompat="@drawable/ic_pause_white_64dp"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/roundSelector"
android:padding="16dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/playPauseButton"
app:layout_constraintEnd_toStartOf="@+id/shuffleButton"
app:layout_constraintStart_toEndOf="@+id/playPauseButton"
app:layout_constraintTop_toTopOf="@+id/playPauseButton"
app:srcCompat="@drawable/ic_skip_next_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/shuffleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/roundSelector"
android:padding="16dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/nextButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/nextButton"
app:layout_constraintTop_toTopOf="@+id/nextButton"
app:srcCompat="@drawable/ic_shuffle_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<FrameLayout
android:id="@+id/volumeFragmentContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingStart="8dp"
android:paddingEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
tools:background="@color/md_red_400"
tools:layout_height="52dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -57,6 +57,27 @@
tools:progress="20" /> tools:progress="20" />
</RelativeLayout> </RelativeLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@color/md_red_500"
android:ellipsize="end"
android:maxLines="1"
android:padding="4dp"
android:textAllCaps="true"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressContainer"
tools:text="@tools:sample/full_names" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/text" android:id="@+id/text"
@ -66,7 +87,6 @@
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:background="@color/md_red_500" android:background="@color/md_red_500"
android:ellipsize="end" android:ellipsize="end"
android:fontFeatureSettings="smcp"
android:letterSpacing="0.1" android:letterSpacing="0.1"
android:maxLines="1" android:maxLines="1"
android:padding="4dp" android:padding="4dp"
@ -79,8 +99,8 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressContainer" app:layout_constraintTop_toBottomOf="@+id/songInfo"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/full_names" />
<LinearLayout <LinearLayout
android:id="@+id/titleContainer" android:id="@+id/titleContainer"
@ -113,7 +133,7 @@
android:singleLine="true" android:singleLine="true"
android:textAllCaps="true" android:textAllCaps="true"
android:textStyle="bold" android:textStyle="bold"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/full_names" />
</LinearLayout> </LinearLayout>

View file

@ -8,7 +8,6 @@
android:orientation="vertical" android:orientation="vertical"
tools:background="@color/md_grey_800"> tools:background="@color/md_grey_800">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/playerMenu" android:id="@+id/playerMenu"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -200,8 +199,26 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@id/songInfo"
app:layout_constraintTop_toBottomOf="@+id/playPauseButton" app:layout_constraintTop_toBottomOf="@+id/playPauseButton"
tools:background="@color/md_red_400" tools:background="@color/md_red_400"
tools:layout_height="52dp" /> tools:layout_height="52dp" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp"
android:textColor="@color/md_white_1000"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="@tools:sample/lorem/random" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -59,7 +59,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height" android:layout_height="@dimen/toolbar_height"

View file

@ -103,13 +103,28 @@
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:textAppearance="@style/TextViewBody1" android:textAppearance="@style/TextViewBody1"
app:layout_constraintBottom_toTopOf="@+id/playPauseButton" app:layout_constraintBottom_toTopOf="@+id/songInfo"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleContainer" app:layout_constraintTop_toBottomOf="@+id/titleContainer"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem/random" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/repeatButton" android:id="@+id/repeatButton"
@ -152,7 +167,7 @@
app:layout_constraintEnd_toStartOf="@+id/nextButton" app:layout_constraintEnd_toStartOf="@+id/nextButton"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/previousButton" app:layout_constraintStart_toEndOf="@+id/previousButton"
app:layout_constraintTop_toBottomOf="@+id/text" app:layout_constraintTop_toBottomOf="@+id/songInfo"
app:srcCompat="@drawable/ic_pause_white_64dp" app:srcCompat="@drawable/ic_pause_white_64dp"
tools:tint="@color/md_black_1000" /> tools:tint="@color/md_black_1000" />

View file

@ -70,7 +70,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/text" app:layout_constraintBottom_toTopOf="@+id/text"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageContainer" app:layout_constraintStart_toEndOf="@id/imageContainer"
app:layout_constraintTop_toBottomOf="@+id/toolbarContainer"> app:layout_constraintTop_toBottomOf="@+id/toolbarContainer">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
@ -95,22 +95,37 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textAppearance="@style/TextViewBody2" android:textAppearance="@style/TextViewBody2"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toBottomOf="@+id/imageContainer" app:layout_constraintBottom_toTopOf="@+id/songInfo"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageContainer" app:layout_constraintStart_toEndOf="@id/imageContainer"
app:layout_constraintTop_toBottomOf="@+id/titleContainer" app:layout_constraintTop_toBottomOf="@+id/titleContainer"
tools:text="@tools:sample/lorem" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@id/imageContainer"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/imageContainer"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
<FrameLayout <FrameLayout
android:id="@+id/playbackControlsFragmentContainer" android:id="@+id/playbackControlsFragmentContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/imageContainer"> app:layout_constraintTop_toBottomOf="@+id/songInfo">
<fragment <fragment
android:id="@+id/playbackControlsFragment" android:id="@+id/playbackControlsFragment"

View file

@ -139,9 +139,26 @@
android:layout_weight="0" android:layout_weight="0"
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@id/songInfo"
tools:backgroundTint="@color/md_red_400" tools:backgroundTint="@color/md_red_400"
tools:layout_height="52dp" /> tools:layout_height="52dp" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="@tools:sample/lorem/random" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -101,10 +101,26 @@
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:textAppearance="@style/TextViewBody1" android:textAppearance="@style/TextViewBody1"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toTopOf="@+id/playPauseButton" app:layout_constraintBottom_toTopOf="@+id/songInfo"
app:layout_constraintTop_toBottomOf="@+id/titleContainer" app:layout_constraintTop_toBottomOf="@+id/titleContainer"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="@tools:sample/lorem/random" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/repeatButton" android:id="@+id/repeatButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -145,7 +161,7 @@
app:layout_constraintEnd_toStartOf="@+id/nextButton" app:layout_constraintEnd_toStartOf="@+id/nextButton"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/previousButton" app:layout_constraintStart_toEndOf="@+id/previousButton"
app:layout_constraintTop_toBottomOf="@+id/text" app:layout_constraintTop_toBottomOf="@+id/songInfo"
app:srcCompat="@drawable/ic_pause_white_64dp" app:srcCompat="@drawable/ic_pause_white_64dp"
tools:tint="@color/md_black_1000" /> tools:tint="@color/md_black_1000" />

View file

@ -58,15 +58,28 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:textAppearance="@style/TextViewSubtitle2" android:textAppearance="@style/TextViewSubtitle2"
app:layout_constraintBottom_toTopOf="@+id/playerMediaControllerContainer" app:layout_constraintBottom_toTopOf="@+id/songInfo"
app:layout_constraintTop_toBottomOf="@+id/text" app:layout_constraintTop_toBottomOf="@+id/text"
tools:layout_editor_absoluteX="16dp" tools:layout_editor_absoluteX="16dp"
tools:text="22.00/ 33.00" /> tools:text="22.00/ 33.00" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/songInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@+id/playerMediaControllerContainer"
app:layout_constraintTop_toBottomOf="@+id/songCurrentProgress"
tools:text="@tools:sample/lorem/random" />
<RelativeLayout <RelativeLayout
android:id="@+id/playerMediaControllerContainer" android:id="@+id/playerMediaControllerContainer"
@ -76,7 +89,7 @@
android:paddingStart="4dp" android:paddingStart="4dp"
android:paddingEnd="4dp" android:paddingEnd="4dp"
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer" app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
app:layout_constraintTop_toBottomOf="@+id/songCurrentProgress" app:layout_constraintTop_toBottomOf="@+id/songInfo"
tools:ignore="ContentDescription,UnusedAttribute" tools:ignore="ContentDescription,UnusedAttribute"
tools:showIn="@layout/fragment_player_playback_controls"> tools:showIn="@layout/fragment_player_playback_controls">

View file

@ -51,16 +51,37 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end" android:layout_gravity="end"
android:ellipsize="end"
android:maxLines="1"
android:padding="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewHeadline3" android:textAppearance="@style/TextViewHeadline3"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent" app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/playbackControlsFragmentContainer"
app:layout_constraintEnd_toStartOf="@+id/songInfo"
app:layout_constraintTop_toBottomOf="@id/status_bar" app:layout_constraintTop_toBottomOf="@id/status_bar"
app:layout_constraintVertical_bias="0"
tools:ignore="MissingPrefix" tools:ignore="MissingPrefix"
tools:text="@tools:sample/date/hhmm" /> tools:text="@tools:sample/date/hhmm" />
<code.name.monkey.retromusic.views.VerticalTextView
android:id="@+id/songInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/playbackControlsFragmentContainer"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_bar"
app:layout_constraintVertical_bias="0"
tools:ignore="MissingPrefix"
tools:text="@tools:sample/lorem" />
<FrameLayout <FrameLayout
android:id="@+id/toolbarContainer" android:id="@+id/toolbarContainer"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -33,5 +33,6 @@
android:paddingStart="12dp" android:paddingStart="12dp"
android:textAppearance="@style/TextViewNormal" android:textAppearance="@style/TextViewNormal"
tools:ignore="MissingPrefix" tools:ignore="MissingPrefix"
android:textColor="?android:attr/textColorPrimary"
tools:text="@tools:sample/full_names" /> tools:text="@tools:sample/full_names" />
</LinearLayout> </LinearLayout>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -11,73 +11,79 @@
tools:ignore="ContentDescription,UnusedAttribute"> tools:ignore="ContentDescription,UnusedAttribute">
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/previousButton" android:id="@+id/repeatButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="8dp"
android:layout_toStartOf="@+id/dummy_fab"
android:background="?attr/roundSelector" android:background="?attr/roundSelector"
android:padding="16dp" android:padding="16dp"
android:scaleType="fitCenter" android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/previousButton"
app:layout_constraintEnd_toStartOf="@+id/previousButton"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/previousButton"
app:srcCompat="@drawable/ic_repeat_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/previousButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/roundSelector"
android:padding="16dp"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/playPauseButton"
app:layout_constraintEnd_toStartOf="@+id/playPauseButton"
app:layout_constraintStart_toEndOf="@+id/repeatButton"
app:layout_constraintTop_toTopOf="@+id/playPauseButton"
app:srcCompat="@drawable/ic_skip_previous_white_24dp" app:srcCompat="@drawable/ic_skip_previous_white_24dp"
tools:ignore="MissingPrefix" tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" /> tools:tint="@color/md_black_1000" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/playPauseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?attr/roundSelector"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/nextButton"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/previousButton"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_pause_white_64dp"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/nextButton" android:id="@+id/nextButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="8dp"
android:layout_toEndOf="@+id/dummy_fab"
android:background="?attr/roundSelector" android:background="?attr/roundSelector"
android:padding="16dp" android:padding="16dp"
android:scaleType="fitCenter" android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/playPauseButton"
app:layout_constraintEnd_toStartOf="@+id/shuffleButton"
app:layout_constraintStart_toEndOf="@+id/playPauseButton"
app:layout_constraintTop_toTopOf="@+id/playPauseButton"
app:srcCompat="@drawable/ic_skip_next_white_24dp" app:srcCompat="@drawable/ic_skip_next_white_24dp"
tools:ignore="MissingPrefix" tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" /> tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/repeatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:background="?attr/roundSelector"
android:padding="16dp"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_repeat_white_24dp"
tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/shuffleButton" android:id="@+id/shuffleButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="?attr/roundSelector" android:background="?attr/roundSelector"
android:padding="16dp" android:padding="16dp"
android:scaleType="fitCenter" android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="@+id/nextButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/nextButton"
app:layout_constraintTop_toTopOf="@+id/nextButton"
app:srcCompat="@drawable/ic_shuffle_white_24dp" app:srcCompat="@drawable/ic_shuffle_white_24dp"
tools:ignore="MissingPrefix" tools:ignore="MissingPrefix"
tools:tint="@color/md_black_1000" /> tools:tint="@color/md_black_1000" />
<Space </androidx.constraintlayout.widget.ConstraintLayout>
android:id="@+id/dummy_fab"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_centerInParent="true" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/playPauseButton"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_centerInParent="true"
android:background="@drawable/color_circle_gradient"
android:elevation="4dp"
android:padding="16dp"
app:srcCompat="@drawable/ic_play_arrow_white_32dp" />
</RelativeLayout>

View file

@ -403,6 +403,8 @@
<string name="no_lyrics_found">No lyrics found</string> <string name="no_lyrics_found">No lyrics found</string>
<string name="no_playing_queue">No songs playing</string>
<string name="no_playlists">You have no playlists</string> <string name="no_playlists">You have no playlists</string>
<string name="no_purchase_found">No purchase found.</string> <string name="no_purchase_found">No purchase found.</string>
@ -420,6 +422,7 @@
<string name="not_listed_in_media_store"><![CDATA[<b>%s</b> is not listed in the media store.]]></string> <string name="not_listed_in_media_store"><![CDATA[<b>%s</b> is not listed in the media store.]]></string>
<string name="nothing_to_scan">Nothing to scan.</string> <string name="nothing_to_scan">Nothing to scan.</string>
<string name="nothing_to_see">Nothing to see</string>
<string name="notification">Notification</string> <string name="notification">Notification</string>
@ -483,8 +486,10 @@
<string name="pref_filter_song_summary">Filter songs by length</string> <string name="pref_filter_song_summary">Filter songs by length</string>
<string name="pref_filter_song_title">Filter song duration</string> <string name="pref_filter_song_title">Filter song duration</string>
<string name="pref_header_advanced">Advanced</string>
<string name="pref_header_album">Album style</string> <string name="pref_header_album">Album style</string>
<string name="pref_header_audio">Audio</string> <string name="pref_header_audio">Audio</string>
<string name="pref_header_blacklist">Blacklist</string>
<string name="pref_header_controls">Controls</string> <string name="pref_header_controls">Controls</string>
<string name="pref_header_general">Theme</string> <string name="pref_header_general">Theme</string>
<string name="pref_header_images">Images</string> <string name="pref_header_images">Images</string>
@ -515,6 +520,7 @@
<string name="pref_summary_desaturated_color">As per Material Design guide lines in dark mode colors should be desaturated</string> <string name="pref_summary_desaturated_color">As per Material Design guide lines in dark mode colors should be desaturated</string>
<string name="pref_summary_dominant_color">Most dominant color will be picked from the album or artist cover</string> <string name="pref_summary_dominant_color">Most dominant color will be picked from the album or artist cover</string>
<string name="pref_summary_extra_controls">Add extra controls for mini player</string> <string name="pref_summary_extra_controls">Add extra controls for mini player</string>
<string name="pref_summary_extra_song_info">Show extra Song information, such as file format, bitrate and frequency</string>
<string name="pref_summary_gapless_playback">"Can cause playback issues on some devices."</string> <string name="pref_summary_gapless_playback">"Can cause playback issues on some devices."</string>
<string name="pref_summary_genre_toggle">Toggle genre tab</string> <string name="pref_summary_genre_toggle">Toggle genre tab</string>
<string name="pref_summary_home_banner">Toggle home banner style</string> <string name="pref_summary_home_banner">Toggle home banner style</string>
@ -545,6 +551,7 @@
<string name="pref_title_colored_notification">Colored notification</string> <string name="pref_title_colored_notification">Colored notification</string>
<string name="pref_title_desaturated_color">Desaturated color</string> <string name="pref_title_desaturated_color">Desaturated color</string>
<string name="pref_title_extra_controls">Extra controls</string> <string name="pref_title_extra_controls">Extra controls</string>
<string name="pref_title_extra_song_info">Song info</string>
<string name="pref_title_gapless_playback">Gapless playback</string> <string name="pref_title_gapless_playback">Gapless playback</string>
<string name="pref_title_general_theme">App theme</string> <string name="pref_title_general_theme">App theme</string>
<string name="pref_title_genre_toggle">Show genre tab</string> <string name="pref_title_genre_toggle">Show genre tab</string>
@ -810,9 +817,4 @@
<string name="you_will_be_forwarded_to_the_issue_tracker_website">You will be forwarded to the issue tracker website.</string> <string name="you_will_be_forwarded_to_the_issue_tracker_website">You will be forwarded to the issue tracker website.</string>
<string name="your_account_data_is_only_used_for_authentication">Your account data is only used for authentication.</string> <string name="your_account_data_is_only_used_for_authentication">Your account data is only used for authentication.</string>
<string name="pref_header_advanced">Advanced</string>
<string name="pref_header_blacklist">Blacklist</string>
<string name="no_playing_queue">No songs playing</string>
<string name="nothing_to_see">Nothing to see</string>
</resources> </resources>

View file

@ -49,10 +49,10 @@
android:title="@string/pref_title_home_banner" /> android:title="@string/pref_title_home_banner" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference <code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="hide_home_banner_search" android:key="extra_song_info"
android:layout="@layout/list_item_view_switch" android:layout="@layout/list_item_view_switch"
android:summary="@string/pref_summary_home_banner" android:summary="@string/pref_summary_extra_song_info"
android:title="@string/pref_title_home_banner" /> android:title="@string/pref_title_extra_song_info" />
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory> </code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>

View file

@ -17,7 +17,6 @@ import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.RadioButton; import android.widget.RadioButton;
import androidx.annotation.CheckResult; import androidx.annotation.CheckResult;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -36,55 +35,266 @@ import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.widget.ToolbarWidgetWrapper; import androidx.appcompat.widget.ToolbarWidgetWrapper;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
import code.name.monkey.appthemehelper.R;
import code.name.monkey.appthemehelper.ThemeStore;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import code.name.monkey.appthemehelper.R;
import code.name.monkey.appthemehelper.ThemeStore;
public final class ToolbarContentTintHelper { public final class ToolbarContentTintHelper {
private ToolbarContentTintHelper() { public static class InternalToolbarContentTintUtil {
}
public static void tintAllIcons(Menu menu, final int color) { public static final class SearchViewTintUtil {
for (int i = 0; i < menu.size(); ++i) {
final MenuItem item = menu.getItem(i);
tintMenuItemIcon(color, item);
tintShareIconIfPresent(color, item);
}
}
private static void tintMenuItemIcon(int color, MenuItem item) { public static void setSearchViewContentColor(View searchView, final @ColorInt int color) {
final Drawable drawable = item.getIcon(); if (searchView == null) {
if (drawable != null) { return;
final Drawable wrapped = DrawableCompat.wrap(drawable); }
drawable.mutate(); final Class<?> cls = searchView.getClass();
DrawableCompat.setTint(wrapped, color); try {
item.setIcon(drawable); final Field mSearchSrcTextViewField = cls.getDeclaredField("mSearchSrcTextView");
} mSearchSrcTextViewField.setAccessible(true);
} final EditText mSearchSrcTextView = (EditText) mSearchSrcTextViewField.get(searchView);
mSearchSrcTextView.setTextColor(color);
mSearchSrcTextView.setHintTextColor(ColorUtil.INSTANCE.adjustAlpha(color, 0.5f));
TintHelper.setCursorTint(mSearchSrcTextView, color);
private static void tintShareIconIfPresent(int color, MenuItem item) { Field field = cls.getDeclaredField("mSearchButton");
if (item.getActionView() != null) { tintImageView(searchView, field, color);
final View actionView = item.getActionView(); field = cls.getDeclaredField("mGoButton");
final View expandActivitiesButton = actionView.findViewById(R.id.expand_activities_button); tintImageView(searchView, field, color);
if (expandActivitiesButton != null) { field = cls.getDeclaredField("mCloseButton");
final ImageView image = (ImageView) expandActivitiesButton.findViewById(R.id.image); tintImageView(searchView, field, color);
if (image != null) { field = cls.getDeclaredField("mVoiceButton");
final Drawable drawable = image.getDrawable(); tintImageView(searchView, field, color);
final Drawable wrapped = DrawableCompat.wrap(drawable); } catch (Exception e) {
drawable.mutate(); e.printStackTrace();
DrawableCompat.setTint(wrapped, color);
image.setImageDrawable(drawable);
} }
} }
private SearchViewTintUtil() {
}
private static void tintImageView(Object target, Field field, final @ColorInt int color)
throws Exception {
field.setAccessible(true);
final ImageView imageView = (ImageView) field.get(target);
if (imageView.getDrawable() != null) {
imageView
.setImageDrawable(
TintHelper.createTintedDrawable(imageView.getDrawable(), color));
}
}
}
public static void applyOverflowMenuTint(final @NonNull Context context, final Toolbar toolbar,
final @ColorInt int color) {
if (toolbar == null) {
return;
}
toolbar.post(new Runnable() {
@Override
public void run() {
try {
Field f1 = Toolbar.class.getDeclaredField("mMenuView");
f1.setAccessible(true);
ActionMenuView actionMenuView = (ActionMenuView) f1.get(toolbar);
Field f2 = ActionMenuView.class.getDeclaredField("mPresenter");
f2.setAccessible(true);
// Actually ActionMenuPresenter
BaseMenuPresenter presenter = (BaseMenuPresenter) f2.get(actionMenuView);
Field f3 = presenter.getClass().getDeclaredField("mOverflowPopup");
f3.setAccessible(true);
MenuPopupHelper overflowMenuPopupHelper = (MenuPopupHelper) f3.get(presenter);
setTintForMenuPopupHelper(context, overflowMenuPopupHelper, color);
Field f4 = presenter.getClass().getDeclaredField("mActionButtonPopup");
f4.setAccessible(true);
MenuPopupHelper subMenuPopupHelper = (MenuPopupHelper) f4.get(presenter);
setTintForMenuPopupHelper(context, subMenuPopupHelper, color);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public static void setOverflowButtonColor(@NonNull Activity activity,
final @ColorInt int color) {
final String overflowDescription = activity
.getString(R.string.abc_action_menu_overflow_description);
final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final ArrayList<View> outViews = new ArrayList<>();
decorView.findViewsWithText(outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
if (outViews.isEmpty()) {
return;
}
final AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
overflow.setImageDrawable(TintHelper.createTintedDrawable(overflow.getDrawable(), color));
ViewUtil.INSTANCE.removeOnGlobalLayoutListener(decorView, this);
}
});
}
public static void setTintForMenuPopupHelper(final @NonNull Context context,
@Nullable MenuPopupHelper menuPopupHelper, final @ColorInt int color) {
try {
if (menuPopupHelper != null) {
final ListView listView = ((ShowableListMenu) menuPopupHelper.getPopup()).getListView();
listView.getViewTreeObserver()
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
try {
Field checkboxField = ListMenuItemView.class.getDeclaredField("mCheckBox");
checkboxField.setAccessible(true);
Field radioButtonField = ListMenuItemView.class
.getDeclaredField("mRadioButton");
radioButtonField.setAccessible(true);
final boolean isDark = !ColorUtil.INSTANCE.isColorLight(
ATHUtil.INSTANCE
.resolveColor(context, android.R.attr.windowBackground));
for (int i = 0; i < listView.getChildCount(); i++) {
View v = listView.getChildAt(i);
if (!(v instanceof ListMenuItemView)) {
continue;
}
ListMenuItemView iv = (ListMenuItemView) v;
CheckBox check = (CheckBox) checkboxField.get(iv);
if (check != null) {
TintHelper.setTint(check, color, isDark);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
check.setBackground(null);
}
}
RadioButton radioButton = (RadioButton) radioButtonField.get(iv);
if (radioButton != null) {
TintHelper.setTint(radioButton, color, isDark);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
radioButton.setBackground(null);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
listView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
//noinspection deprecation
listView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings("unchecked")
public static void tintMenu(@NonNull Toolbar toolbar, @Nullable Menu menu,
final @ColorInt int color) {
try {
final Field field = Toolbar.class.getDeclaredField("mCollapseIcon");
field.setAccessible(true);
Drawable collapseIcon = (Drawable) field.get(toolbar);
if (collapseIcon != null) {
field.set(toolbar, TintHelper.createTintedDrawable(collapseIcon, color));
}
} catch (Exception e) {
e.printStackTrace();
}
if (menu != null && menu.size() > 0) {
for (int i = 0; i < menu.size(); i++) {
final MenuItem item = menu.getItem(i);
if (item.getIcon() != null) {
item.setIcon(TintHelper.createTintedDrawable(item.getIcon(), color));
}
// Search view theming
if (item.getActionView() != null && (
item.getActionView() instanceof android.widget.SearchView || item
.getActionView() instanceof androidx.appcompat.widget.SearchView)) {
SearchViewTintUtil.setSearchViewContentColor(item.getActionView(), color);
}
}
}
}
private InternalToolbarContentTintUtil() {
}
}
private static class ATHMenuPresenterCallback implements MenuPresenter.Callback {
private int mColor;
private Context mContext;
private MenuPresenter.Callback mParentCb;
private Toolbar mToolbar;
public ATHMenuPresenterCallback(Context context, final @ColorInt int color,
MenuPresenter.Callback parentCb, Toolbar toolbar) {
mContext = context;
mColor = color;
mParentCb = parentCb;
mToolbar = toolbar;
}
@Override
public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
if (mParentCb != null) {
mParentCb.onCloseMenu(menu, allMenusAreClosing);
}
}
@Override
public boolean onOpenSubMenu(MenuBuilder subMenu) {
InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor);
return mParentCb != null && mParentCb.onOpenSubMenu(subMenu);
}
}
private static class ATHOnMenuItemClickListener implements Toolbar.OnMenuItemClickListener {
private int mColor;
private Context mContext;
private Toolbar.OnMenuItemClickListener mParentListener;
private Toolbar mToolbar;
public ATHOnMenuItemClickListener(Context context, final @ColorInt int color,
Toolbar.OnMenuItemClickListener parentCb, Toolbar toolbar) {
mContext = context;
mColor = color;
mParentListener = parentCb;
mToolbar = toolbar;
}
@Override
public boolean onMenuItemClick(MenuItem item) {
InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor);
return mParentListener != null && mParentListener.onMenuItemClick(item);
} }
} }
public static void colorBackButton(@NonNull Toolbar toolbar) { public static void colorBackButton(@NonNull Toolbar toolbar) {
int color = ATHUtil.INSTANCE.resolveColor(toolbar.getContext(), R.attr.colorControlNormal); int color = ATHUtil.INSTANCE.resolveColor(toolbar.getContext(), R.attr.colorControlNormal);
final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY); final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY);
for (int i = 0; i < toolbar.getChildCount(); i++) { for (int i = 0; i < toolbar.getChildCount(); i++) {
final View backButton = toolbar.getChildAt(i); final View backButton = toolbar.getChildAt(i);
@ -102,7 +312,7 @@ public final class ToolbarContentTintHelper {
* @param activity reference to activity needed to register observers * @param activity reference to activity needed to register observers
*/ */
public static void colorizeToolbar(Toolbar toolbarView, int toolbarIconsColor, public static void colorizeToolbar(Toolbar toolbarView, int toolbarIconsColor,
Activity activity) { Activity activity) {
final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(toolbarIconsColor, final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(toolbarIconsColor,
PorterDuff.Mode.MULTIPLY); PorterDuff.Mode.MULTIPLY);
@ -150,93 +360,64 @@ public final class ToolbarContentTintHelper {
} }
} }
/** @Nullable
* It's important to set overflowDescription atribute in styles, so we can grab the reference to public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) {
* the overflow icon. Check: res/values/styles.xml if (ab == null || !(ab instanceof WindowDecorActionBar)) {
*/ return null;
private static void setOverflowButtonColor(final Activity activity, }
final PorterDuffColorFilter colorFilter) { try {
final String overflowDescription = activity WindowDecorActionBar decorAb = (WindowDecorActionBar) ab;
.getString(R.string.abc_action_menu_overflow_description); Field field = WindowDecorActionBar.class.getDeclaredField("mDecorToolbar");
final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); field.setAccessible(true);
final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver(); ToolbarWidgetWrapper wrapper = (ToolbarWidgetWrapper) field.get(decorAb);
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { field = ToolbarWidgetWrapper.class.getDeclaredField("mToolbar");
@Override field.setAccessible(true);
public void onGlobalLayout() { return (Toolbar) field.get(wrapper);
final ArrayList<View> outViews = new ArrayList<View>(); } catch (Throwable t) {
decorView.findViewsWithText(outViews, overflowDescription, throw new RuntimeException(
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION); "Failed to retrieve Toolbar from AppCompat support ActionBar: " + t.getMessage(), t);
if (outViews.isEmpty()) { }
return;
}
final ActionMenuView overflowViewParent = (ActionMenuView) outViews.get(0).getParent();
overflowViewParent.getOverflowIcon().setColorFilter(colorFilter);
removeOnGlobalLayoutListener(decorView, this);
}
});
} }
private static void setOverflowButtonColor(final Activity activity, final Toolbar toolbar, public static void handleOnCreateOptionsMenu(
final int toolbarIconsColor) { @NonNull Context context,
final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); @NonNull Toolbar toolbar,
final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver(); @NonNull Menu menu,
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { int toolbarColor) {
@Override setToolbarContentColorBasedOnToolbarColor(context, toolbar, menu, toolbarColor);
public void onGlobalLayout() {
if (toolbar != null && toolbar.getOverflowIcon() != null) {
Drawable bg = DrawableCompat.wrap(toolbar.getOverflowIcon());
DrawableCompat.setTint(bg, toolbarIconsColor);
}
removeOnGlobalLayoutListener(decorView, this);
}
});
} }
private static void removeOnGlobalLayoutListener(View v, public static void handleOnCreateOptionsMenu(Context context, Toolbar toolbar, Menu menu,
ViewTreeObserver.OnGlobalLayoutListener listener) { @ColorInt int toolbarContentColor, @ColorInt int titleTextColor,
v.getViewTreeObserver().removeOnGlobalLayoutListener(listener); @ColorInt int subtitleTextColor, @ColorInt int menuWidgetColor) {
setToolbarContentColor(context, toolbar, menu, toolbarContentColor, titleTextColor,
subtitleTextColor, menuWidgetColor);
} }
public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context, public static void handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar) {
Toolbar toolbar, handleOnPrepareOptionsMenu(activity, toolbar, ThemeStore.Companion.accentColor(activity));
int toolbarColor) {
setToolbarContentColorBasedOnToolbarColor(context, toolbar, null, toolbarColor);
} }
public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context, public static void handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar,
Toolbar toolbar, int widgetColor) {
@Nullable Menu menu, InternalToolbarContentTintUtil.applyOverflowMenuTint(activity, toolbar, widgetColor);
int toolbarColor) {
setToolbarContentColorBasedOnToolbarColor(context, toolbar, menu, toolbarColor,
ThemeStore.Companion.accentColor(context));
}
public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context,
Toolbar toolbar,
@Nullable Menu menu,
int toolbarColor,
final @ColorInt int menuWidgetColor) {
setToolbarContentColor(context, toolbar, menu, toolbarContentColor(context, toolbarColor),
toolbarTitleColor(context, toolbarColor), toolbarSubtitleColor(context, toolbarColor),
menuWidgetColor);
} }
public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar, public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar,
final @ColorInt int toolbarContentColor, final @ColorInt int primaryTextColor, final @ColorInt int toolbarContentColor, final @ColorInt int primaryTextColor,
final @ColorInt int secondaryTextColor, final @ColorInt int menuWidgetColor) { final @ColorInt int secondaryTextColor, final @ColorInt int menuWidgetColor) {
setToolbarContentColor(context, toolbar, null, toolbarContentColor, primaryTextColor, setToolbarContentColor(context, toolbar, null, toolbarContentColor, primaryTextColor,
secondaryTextColor, menuWidgetColor); secondaryTextColor, menuWidgetColor);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static void setToolbarContentColor(@NonNull Context context, public static void setToolbarContentColor(@NonNull Context context,
Toolbar toolbar, Toolbar toolbar,
@Nullable Menu menu, @Nullable Menu menu,
final @ColorInt int toolbarContentColor, final @ColorInt int toolbarContentColor,
final @ColorInt int titleTextColor, final @ColorInt int titleTextColor,
final @ColorInt int subtitleTextColor, final @ColorInt int subtitleTextColor,
final @ColorInt int menuWidgetColor) { final @ColorInt int menuWidgetColor) {
if (toolbar == null) { if (toolbar == null) {
return; return;
} }
@ -258,8 +439,7 @@ public final class ToolbarContentTintHelper {
InternalToolbarContentTintUtil.applyOverflowMenuTint(context, toolbar, menuWidgetColor); InternalToolbarContentTintUtil.applyOverflowMenuTint(context, toolbar, menuWidgetColor);
if (context instanceof Activity) { if (context instanceof Activity) {
InternalToolbarContentTintUtil InternalToolbarContentTintUtil.setOverflowButtonColor((Activity) context, toolbarContentColor);
.setOverflowButtonColor((Activity) context, toolbarContentColor);
} }
try { try {
@ -288,7 +468,8 @@ public final class ToolbarContentTintHelper {
final Field menuItemClickListener = Toolbar.class final Field menuItemClickListener = Toolbar.class
.getDeclaredField("mOnMenuItemClickListener"); .getDeclaredField("mOnMenuItemClickListener");
menuItemClickListener.setAccessible(true); menuItemClickListener.setAccessible(true);
Toolbar.OnMenuItemClickListener currentClickListener = (Toolbar.OnMenuItemClickListener) menuItemClickListener Toolbar.OnMenuItemClickListener currentClickListener
= (Toolbar.OnMenuItemClickListener) menuItemClickListener
.get(toolbar); .get(toolbar);
if (!(currentClickListener instanceof ATHOnMenuItemClickListener)) { if (!(currentClickListener instanceof ATHOnMenuItemClickListener)) {
final ATHOnMenuItemClickListener newClickListener = new ATHOnMenuItemClickListener(context, final ATHOnMenuItemClickListener newClickListener = new ATHOnMenuItemClickListener(context,
@ -300,44 +481,38 @@ public final class ToolbarContentTintHelper {
} }
} }
@Nullable public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context,
public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) { Toolbar toolbar,
if (ab == null || !(ab instanceof WindowDecorActionBar)) { int toolbarColor) {
return null; setToolbarContentColorBasedOnToolbarColor(context, toolbar, null, toolbarColor);
}
public static void setToolbarContentColorBasedOnToolbarColor(
@NonNull Context context,
@NonNull Toolbar toolbar,
@Nullable Menu menu,
int toolbarColor) {
setToolbarContentColorBasedOnToolbarColor(context, toolbar, menu, toolbarColor,
ThemeStore.Companion.accentColor(context));
}
public static void setToolbarContentColorBasedOnToolbarColor(
@NonNull Context context,
@NonNull Toolbar toolbar,
@Nullable Menu menu,
int toolbarColor,
final @ColorInt int menuWidgetColor) {
setToolbarContentColor(context, toolbar, menu, toolbarContentColor(context, toolbarColor),
toolbarTitleColor(context, toolbarColor), toolbarSubtitleColor(context, toolbarColor),
menuWidgetColor);
}
public static void tintAllIcons(Menu menu, final int color) {
for (int i = 0; i < menu.size(); ++i) {
final MenuItem item = menu.getItem(i);
tintMenuItemIcon(color, item);
tintShareIconIfPresent(color, item);
} }
try {
WindowDecorActionBar decorAb = (WindowDecorActionBar) ab;
Field field = WindowDecorActionBar.class.getDeclaredField("mDecorToolbar");
field.setAccessible(true);
ToolbarWidgetWrapper wrapper = (ToolbarWidgetWrapper) field.get(decorAb);
field = ToolbarWidgetWrapper.class.getDeclaredField("mToolbar");
field.setAccessible(true);
return (Toolbar) field.get(wrapper);
} catch (Throwable t) {
throw new RuntimeException(
"Failed to retrieve Toolbar from AppCompat support ActionBar: " + t.getMessage(), t);
}
}
public static void handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar) {
handleOnPrepareOptionsMenu(activity, toolbar, ThemeStore.Companion.accentColor(activity));
}
public static void handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar,
int widgetColor) {
InternalToolbarContentTintUtil.applyOverflowMenuTint(activity, toolbar, widgetColor);
}
public static void handleOnCreateOptionsMenu(Context context, Toolbar toolbar, Menu menu,
int toolbarColor) {
setToolbarContentColorBasedOnToolbarColor(context, toolbar, menu, toolbarColor);
}
public static void handleOnCreateOptionsMenu(Context context, Toolbar toolbar, Menu menu,
@ColorInt int toolbarContentColor, @ColorInt int titleTextColor,
@ColorInt int subtitleTextColor, @ColorInt int menuWidgetColor) {
setToolbarContentColor(context, toolbar, menu, toolbarContentColor, titleTextColor,
subtitleTextColor, menuWidgetColor);
} }
@CheckResult @CheckResult
@ -352,254 +527,90 @@ public final class ToolbarContentTintHelper {
@CheckResult @CheckResult
@ColorInt @ColorInt
public static int toolbarSubtitleColor(@NonNull Context context, @ColorInt int toolbarColor) { public static int toolbarSubtitleColor(@NonNull Context context, @ColorInt int toolbarColor) {
return MaterialValueHelper.INSTANCE.getSecondaryTextColor(context, ColorUtil.INSTANCE.isColorLight(toolbarColor)); return MaterialValueHelper.INSTANCE
.getSecondaryTextColor(context, ColorUtil.INSTANCE.isColorLight(toolbarColor));
} }
@CheckResult @CheckResult
@ColorInt @ColorInt
public static int toolbarTitleColor(@NonNull Context context, @ColorInt int toolbarColor) { public static int toolbarTitleColor(@NonNull Context context, @ColorInt int toolbarColor) {
return MaterialValueHelper.INSTANCE.getPrimaryTextColor(context, ColorUtil.INSTANCE.isColorLight(toolbarColor)); return MaterialValueHelper.INSTANCE
.getPrimaryTextColor(context, ColorUtil.INSTANCE.isColorLight(toolbarColor));
} }
private static class ATHMenuPresenterCallback implements MenuPresenter.Callback { private ToolbarContentTintHelper() {
private Context mContext;
private int mColor;
private MenuPresenter.Callback mParentCb;
private Toolbar mToolbar;
public ATHMenuPresenterCallback(Context context, final @ColorInt int color,
MenuPresenter.Callback parentCb, Toolbar toolbar) {
mContext = context;
mColor = color;
mParentCb = parentCb;
mToolbar = toolbar;
}
@Override
public void onCloseMenu(MenuBuilder menu, boolean allMenusAreClosing) {
if (mParentCb != null) {
mParentCb.onCloseMenu(menu, allMenusAreClosing);
}
}
@Override
public boolean onOpenSubMenu(MenuBuilder subMenu) {
InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor);
return mParentCb != null && mParentCb.onOpenSubMenu(subMenu);
}
} }
private static class ATHOnMenuItemClickListener implements Toolbar.OnMenuItemClickListener { private static void removeOnGlobalLayoutListener(View v,
ViewTreeObserver.OnGlobalLayoutListener listener) {
private Context mContext; v.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
private int mColor;
private Toolbar.OnMenuItemClickListener mParentListener;
private Toolbar mToolbar;
public ATHOnMenuItemClickListener(Context context, final @ColorInt int color,
Toolbar.OnMenuItemClickListener parentCb, Toolbar toolbar) {
mContext = context;
mColor = color;
mParentListener = parentCb;
mToolbar = toolbar;
}
@Override
public boolean onMenuItemClick(MenuItem item) {
InternalToolbarContentTintUtil.applyOverflowMenuTint(mContext, mToolbar, mColor);
return mParentListener != null && mParentListener.onMenuItemClick(item);
}
} }
public static class InternalToolbarContentTintUtil { private static void setOverflowButtonColor(final Activity activity, final Toolbar toolbar,
final int toolbarIconsColor) {
final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
private InternalToolbarContentTintUtil() { if (toolbar != null && toolbar.getOverflowIcon() != null) {
} Drawable bg = DrawableCompat.wrap(toolbar.getOverflowIcon());
DrawableCompat.setTint(bg, toolbarIconsColor);
@SuppressWarnings("unchecked")
public static void tintMenu(@NonNull Toolbar toolbar, @Nullable Menu menu,
final @ColorInt int color) {
try {
final Field field = Toolbar.class.getDeclaredField("mCollapseIcon");
field.setAccessible(true);
Drawable collapseIcon = (Drawable) field.get(toolbar);
if (collapseIcon != null) {
field.set(toolbar, TintHelper.createTintedDrawable(collapseIcon, color));
} }
} catch (Exception e) { removeOnGlobalLayoutListener(decorView, this);
e.printStackTrace();
} }
});
}
if (menu != null && menu.size() > 0) { /**
for (int i = 0; i < menu.size(); i++) { * It's important to set overflowDescription atribute in styles, so we can grab the reference to
final MenuItem item = menu.getItem(i); * the overflow icon. Check: res/values/styles.xml
if (item.getIcon() != null) { */
item.setIcon(TintHelper.createTintedDrawable(item.getIcon(), color)); private static void setOverflowButtonColor(final Activity activity,
} final PorterDuffColorFilter colorFilter) {
// Search view theming final String overflowDescription = activity
if (item.getActionView() != null && ( .getString(R.string.abc_action_menu_overflow_description);
item.getActionView() instanceof android.widget.SearchView || item final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
.getActionView() instanceof androidx.appcompat.widget.SearchView)) { final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
SearchViewTintUtil.setSearchViewContentColor(item.getActionView(), color); viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
} @Override
} public void onGlobalLayout() {
} final ArrayList<View> outViews = new ArrayList<View>();
} decorView.findViewsWithText(outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
public static void applyOverflowMenuTint(final @NonNull Context context, final Toolbar toolbar, if (outViews.isEmpty()) {
final @ColorInt int color) {
if (toolbar == null) {
return;
}
toolbar.post(new Runnable() {
@Override
public void run() {
try {
Field f1 = Toolbar.class.getDeclaredField("mMenuView");
f1.setAccessible(true);
ActionMenuView actionMenuView = (ActionMenuView) f1.get(toolbar);
Field f2 = ActionMenuView.class.getDeclaredField("mPresenter");
f2.setAccessible(true);
// Actually ActionMenuPresenter
BaseMenuPresenter presenter = (BaseMenuPresenter) f2.get(actionMenuView);
Field f3 = presenter.getClass().getDeclaredField("mOverflowPopup");
f3.setAccessible(true);
MenuPopupHelper overflowMenuPopupHelper = (MenuPopupHelper) f3.get(presenter);
setTintForMenuPopupHelper(context, overflowMenuPopupHelper, color);
Field f4 = presenter.getClass().getDeclaredField("mActionButtonPopup");
f4.setAccessible(true);
MenuPopupHelper subMenuPopupHelper = (MenuPopupHelper) f4.get(presenter);
setTintForMenuPopupHelper(context, subMenuPopupHelper, color);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public static void setTintForMenuPopupHelper(final @NonNull Context context,
@Nullable MenuPopupHelper menuPopupHelper, final @ColorInt int color) {
try {
if (menuPopupHelper != null) {
final ListView listView = ((ShowableListMenu) menuPopupHelper.getPopup()).getListView();
listView.getViewTreeObserver()
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
try {
Field checkboxField = ListMenuItemView.class.getDeclaredField("mCheckBox");
checkboxField.setAccessible(true);
Field radioButtonField = ListMenuItemView.class
.getDeclaredField("mRadioButton");
radioButtonField.setAccessible(true);
final boolean isDark = !ColorUtil.INSTANCE.isColorLight(
ATHUtil.INSTANCE.resolveColor(context, android.R.attr.windowBackground));
for (int i = 0; i < listView.getChildCount(); i++) {
View v = listView.getChildAt(i);
if (!(v instanceof ListMenuItemView)) {
continue;
}
ListMenuItemView iv = (ListMenuItemView) v;
CheckBox check = (CheckBox) checkboxField.get(iv);
if (check != null) {
TintHelper.setTint(check, color, isDark);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
check.setBackground(null);
}
}
RadioButton radioButton = (RadioButton) radioButtonField.get(iv);
if (radioButton != null) {
TintHelper.setTint(radioButton, color, isDark);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
radioButton.setBackground(null);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
listView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
//noinspection deprecation
listView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void setOverflowButtonColor(@NonNull Activity activity,
final @ColorInt int color) {
final String overflowDescription = activity
.getString(R.string.abc_action_menu_overflow_description);
final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final ArrayList<View> outViews = new ArrayList<>();
decorView.findViewsWithText(outViews, overflowDescription,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
if (outViews.isEmpty()) {
return;
}
final AppCompatImageView overflow = (AppCompatImageView) outViews.get(0);
overflow.setImageDrawable(TintHelper.createTintedDrawable(overflow.getDrawable(), color));
ViewUtil.INSTANCE.removeOnGlobalLayoutListener(decorView, this);
}
});
}
public static final class SearchViewTintUtil {
private SearchViewTintUtil() {
}
private static void tintImageView(Object target, Field field, final @ColorInt int color)
throws Exception {
field.setAccessible(true);
final ImageView imageView = (ImageView) field.get(target);
if (imageView.getDrawable() != null) {
imageView
.setImageDrawable(
TintHelper.createTintedDrawable(imageView.getDrawable(), color));
}
}
public static void setSearchViewContentColor(View searchView, final @ColorInt int color) {
if (searchView == null) {
return; return;
} }
final Class<?> cls = searchView.getClass(); final ActionMenuView overflowViewParent = (ActionMenuView) outViews.get(0).getParent();
try { overflowViewParent.getOverflowIcon().setColorFilter(colorFilter);
final Field mSearchSrcTextViewField = cls.getDeclaredField("mSearchSrcTextView"); removeOnGlobalLayoutListener(decorView, this);
mSearchSrcTextViewField.setAccessible(true); }
final EditText mSearchSrcTextView = (EditText) mSearchSrcTextViewField.get(searchView); });
mSearchSrcTextView.setTextColor(color); }
mSearchSrcTextView.setHintTextColor(ColorUtil.INSTANCE.adjustAlpha(color, 0.5f));
TintHelper.setCursorTint(mSearchSrcTextView, color);
Field field = cls.getDeclaredField("mSearchButton"); private static void tintMenuItemIcon(int color, MenuItem item) {
tintImageView(searchView, field, color); final Drawable drawable = item.getIcon();
field = cls.getDeclaredField("mGoButton"); if (drawable != null) {
tintImageView(searchView, field, color); final Drawable wrapped = DrawableCompat.wrap(drawable);
field = cls.getDeclaredField("mCloseButton"); drawable.mutate();
tintImageView(searchView, field, color); DrawableCompat.setTint(wrapped, color);
field = cls.getDeclaredField("mVoiceButton"); item.setIcon(drawable);
tintImageView(searchView, field, color); }
} catch (Exception e) { }
e.printStackTrace();
private static void tintShareIconIfPresent(int color, MenuItem item) {
if (item.getActionView() != null) {
final View actionView = item.getActionView();
final View expandActivitiesButton = actionView.findViewById(R.id.expand_activities_button);
if (expandActivitiesButton != null) {
final ImageView image = (ImageView) expandActivitiesButton.findViewById(R.id.image);
if (image != null) {
final Drawable drawable = image.getDrawable();
final Drawable wrapped = DrawableCompat.wrap(drawable);
drawable.mutate();
DrawableCompat.setTint(wrapped, color);
image.setImageDrawable(drawable);
} }
} }
} }