Added song track info
This commit is contained in:
parent
9b89259178
commit
813fb86073
55 changed files with 2267 additions and 1528 deletions
|
@ -16,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
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.R
|
||||
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)
|
||||
val sortOrder = menu.findItem(R.id.action_sort_order)
|
||||
setUpSortOrderMenu(sortOrder.subMenu)
|
||||
ToolbarContentTintHelper.handleOnCreateOptionsMenu(
|
||||
this,
|
||||
toolbar,
|
||||
menu,
|
||||
getToolbarBackgroundColor(toolbar)
|
||||
)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ import android.content.SharedPreferences
|
|||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
|
||||
|
@ -249,6 +251,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
const val APP_INTRO_REQUEST = 2323
|
||||
const val HOME = 0
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
package code.name.monkey.retromusic.fragments.base
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.webkit.MimeTypeMap
|
||||
import androidx.fragment.app.Fragment
|
||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||
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.
|
||||
|
@ -33,7 +41,6 @@ open class AbsMusicServiceFragment : Fragment(), MusicServiceEventListener {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
playerActivity?.addMusicServiceEventListener(this)
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -42,34 +49,50 @@ open class AbsMusicServiceFragment : Fragment(), MusicServiceEventListener {
|
|||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
|
||||
}
|
||||
|
||||
override fun onServiceDisconnected() {
|
||||
|
||||
}
|
||||
|
||||
override fun onQueueChanged() {
|
||||
|
||||
}
|
||||
|
||||
override fun onPlayStateChanged() {
|
||||
|
||||
}
|
||||
|
||||
override fun onRepeatModeChanged() {
|
||||
|
||||
}
|
||||
|
||||
override fun onShuffleModeChanged() {
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import code.name.monkey.retromusic.fragments.VolumeFragment
|
|||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
||||
|
||||
/**
|
||||
* Created by hemanths on 24/09/17.
|
||||
*/
|
||||
|
@ -38,18 +37,18 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgr
|
|||
pivotY = (view.height / 2).toFloat()
|
||||
|
||||
animate().setDuration(200)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.scaleX(1.1f)
|
||||
.scaleY(1.1f)
|
||||
.withEndAction {
|
||||
animate().setDuration(200)
|
||||
.setInterpolator(AccelerateInterpolator())
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.alpha(1f)
|
||||
.start()
|
||||
}
|
||||
.start()
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.scaleX(1.1f)
|
||||
.scaleY(1.1f)
|
||||
.withEndAction {
|
||||
animate().setDuration(200)
|
||||
.setInterpolator(AccelerateInterpolator())
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.alpha(1f)
|
||||
.start()
|
||||
}
|
||||
.start()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,6 +70,4 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgr
|
|||
companion object {
|
||||
const val SLIDER_ANIMATION_TIME: Long = 400
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.view.MenuItem;
|
|||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
|
@ -19,13 +18,6 @@ import androidx.appcompat.widget.Toolbar;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
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.util.ATHUtil;
|
||||
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.RetroColorUtil;
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LibraryFragment extends AbsMainActivityFragment implements CabHolder, MainActivityFragmentCallbacks {
|
||||
|
||||
public static final String TAG = "LibraryFragment";
|
||||
|
||||
private static final String CURRENT_TAB_ID = "current_tab_id";
|
||||
|
||||
private Toolbar toolbar;
|
||||
private AppBarLayout appBarLayout;
|
||||
private MaterialCardView toolbarContainer;
|
||||
|
||||
private MaterialCab cab;
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
private CompositeDisposable disposable;
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
private Toolbar toolbar;
|
||||
|
||||
private MaterialCardView toolbarContainer;
|
||||
|
||||
@NonNull
|
||||
public static Fragment newInstance(int tab) {
|
||||
|
@ -70,17 +70,11 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
return new LibraryFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_library, container, false);
|
||||
disposable = new CompositeDisposable();
|
||||
appBarLayout = view.findViewById(R.id.appBarLayout);
|
||||
|
@ -89,23 +83,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
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
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
@ -114,53 +91,19 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
inflateFragment();
|
||||
}
|
||||
|
||||
private void inflateFragment() {
|
||||
if (getArguments() == null) {
|
||||
selectedFragment(SongsFragment.Companion.newInstance());
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void setupToolbar() {
|
||||
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));
|
||||
public void addOnAppBarOffsetChangedListener(
|
||||
@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
|
||||
appBarLayout.addOnOffsetChangedListener(onOffsetChangedListener);
|
||||
}
|
||||
|
||||
private Fragment getCurrentFragment() {
|
||||
if (fragmentManager == null) {
|
||||
return SongsFragment.Companion.newInstance();
|
||||
}
|
||||
return fragmentManager.findFragmentByTag(LibraryFragment.TAG);
|
||||
public int getTotalAppBarScrollingRange() {
|
||||
return appBarLayout.getTotalScrollRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -172,31 +115,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
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
|
||||
public void onCreateOptionsMenu(@NotNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
@ -205,7 +123,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
Fragment currentFragment = getCurrentFragment();
|
||||
if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||
&& currentFragment.isAdded()) {
|
||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
|
||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment
|
||||
= (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
|
||||
|
||||
MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
|
||||
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_sort_order);
|
||||
} 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);
|
||||
}
|
||||
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
|
||||
|
@ -236,45 +186,76 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
ToolbarContentTintHelper.handleOnPrepareOptionsMenu(activity, toolbar);
|
||||
}
|
||||
|
||||
|
||||
private void setUpSortOrderMenu(
|
||||
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
|
||||
@NonNull SubMenu sortOrderMenu) {
|
||||
String currentSortOrder = fragment.getSortOrder();
|
||||
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));
|
||||
@NonNull
|
||||
@Override
|
||||
public MaterialCab openCab(int menuRes, @NonNull MaterialCab.Callback callback) {
|
||||
if (cab != null && cab.isActive()) {
|
||||
cab.finish();
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -341,33 +322,41 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
}
|
||||
private void inflateFragment() {
|
||||
if (getArguments() == null) {
|
||||
selectedFragment(SongsFragment.Companion.newInstance());
|
||||
return;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
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(
|
||||
@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(
|
||||
@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 (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));
|
||||
}
|
||||
|
||||
if (gridSize > 0) {
|
||||
item.setChecked(true);
|
||||
fragment.setAndSaveGridSize(gridSize);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
sortOrderMenu.setGroupCheckable(0, true, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void setupToolbar() {
|
||||
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));
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
|||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
|
||||
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 {
|
||||
|
||||
|
@ -53,7 +53,10 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
|
|||
lyricsLine1.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()
|
||||
|
||||
lyricsLine1.alpha = 1f
|
||||
|
@ -130,8 +133,10 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
|
|||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as AdaptivePlaybackControlsFragment
|
||||
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playbackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as AdaptivePlaybackControlsFragment
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.apply {
|
||||
removeSlideEffect()
|
||||
setCallbacks(this@AdaptiveFragment)
|
||||
|
@ -184,7 +189,11 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
|
|||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
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() {
|
||||
|
@ -206,5 +215,4 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
|
|||
|
||||
override val paletteColor: Int
|
||||
get() = lastColor
|
||||
|
||||
}
|
|
@ -14,17 +14,26 @@ 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.extensions.hide
|
||||
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.MusicProgressViewUpdateHelper
|
||||
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||
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.PreferenceUtil
|
||||
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() {
|
||||
|
||||
|
@ -37,8 +46,10 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
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_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() {
|
||||
super.onResume()
|
||||
progressViewUpdateHelper!!.start()
|
||||
|
@ -66,10 +85,16 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
progressViewUpdateHelper!!.stop()
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
updateSong()
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
updatePlayPauseDrawableState()
|
||||
updateRepeatState()
|
||||
updateShuffleState()
|
||||
updateSong()
|
||||
}
|
||||
|
||||
override fun onPlayStateChanged() {
|
||||
|
@ -104,7 +129,11 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
ThemeStore.accentColor(context!!)
|
||||
}.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)
|
||||
ViewUtil.setProgressDrawable(progressSlider, colorFinal, true)
|
||||
volumeFragment?.setTintable(colorFinal)
|
||||
|
@ -151,7 +180,10 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -202,8 +234,10 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
MusicPlayerRemote.seekTo(progress)
|
||||
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis)
|
||||
onUpdateProgressViews(
|
||||
MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -16,6 +16,7 @@ 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.extensions.hide
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
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.service.MusicService
|
||||
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() {
|
||||
|
||||
|
@ -36,9 +48,10 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_blur_player_playback_controls, container, false)
|
||||
}
|
||||
|
@ -63,6 +76,12 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
text.text = "${song.artistName} • ${song.albumName}"
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -120,7 +139,11 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -161,7 +184,10 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -189,11 +215,11 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
public override fun show() {
|
||||
playPauseButton!!.animate()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.rotation(360f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.rotation(360f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
}
|
||||
|
||||
public override fun hide() {
|
||||
|
@ -211,8 +237,10 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
MusicPlayerRemote.seekTo(progress)
|
||||
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis)
|
||||
onUpdateProgressViews(
|
||||
MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -228,20 +256,19 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
pivotY = (height / 2).toFloat()
|
||||
|
||||
animate().setDuration(200)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.scaleX(1.1f)
|
||||
.scaleY(1.1f)
|
||||
.withEndAction {
|
||||
animate().setDuration(200)
|
||||
.setInterpolator(AccelerateInterpolator())
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.alpha(1f).start()
|
||||
}.start()
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.scaleX(1.1f)
|
||||
.scaleY(1.1f)
|
||||
.withEndAction {
|
||||
animate().setDuration(200)
|
||||
.setInterpolator(AccelerateInterpolator())
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.alpha(1f).start()
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
progressSlider.max = total
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
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 {
|
||||
|
||||
|
@ -31,9 +32,10 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
|
|||
|
||||
private var lastColor: 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_blur, container, false)
|
||||
}
|
||||
|
||||
|
@ -44,8 +46,10 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
|
|||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as BlurPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playbackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as BlurPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
}
|
||||
|
||||
|
@ -76,11 +80,9 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
|
|||
}
|
||||
|
||||
override fun onShow() {
|
||||
|
||||
}
|
||||
|
||||
override fun onHide() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
|
@ -94,24 +96,23 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
|
|||
override val paletteColor: Int
|
||||
get() = lastColor
|
||||
|
||||
|
||||
private fun updateBlur() {
|
||||
val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
.getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
|
||||
.getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
|
||||
colorBackground!!.clearColorFilter()
|
||||
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
|
||||
.checkIgnoreMediaStore(requireContext())
|
||||
.generatePalette(requireContext()).build()
|
||||
.transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build())
|
||||
//.centerCrop()
|
||||
//.override(320, 480)
|
||||
.into(object : RetroMusicColoredTarget(colorBackground) {
|
||||
override fun onColorReady(color: Int) {
|
||||
if (color == defaultFooterColor) {
|
||||
colorBackground!!.setColorFilter(color)
|
||||
}
|
||||
.checkIgnoreMediaStore(requireContext())
|
||||
.generatePalette(requireContext()).build()
|
||||
.transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build())
|
||||
//.centerCrop()
|
||||
//.override(320, 480)
|
||||
.into(object : RetroMusicColoredTarget(colorBackground) {
|
||||
override fun onColorReady(color: Int) {
|
||||
if (color == defaultFooterColor) {
|
||||
colorBackground!!.setColorFilter(color)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
|
@ -131,7 +132,8 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
|
|||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
PreferenceManager.getDefaultSharedPreferences(requireContext()).unregisterOnSharedPreferenceChangeListener(this)
|
||||
PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
|
@ -139,6 +141,5 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
|
|||
updateBlur()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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.helper.MusicPlayerRemote
|
||||
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() {
|
||||
override fun playerToolbar(): Toolbar {
|
||||
|
@ -62,8 +62,10 @@ class CardFragment : AbsPlayerFragment() {
|
|||
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
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_card_player, container, false)
|
||||
}
|
||||
|
@ -75,8 +77,10 @@ class CardFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playbackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
playerAlbumCoverFragment.removeSlideEffect()
|
||||
}
|
||||
|
@ -87,7 +91,6 @@ class CardFragment : AbsPlayerFragment() {
|
|||
playerToolbar.setOnMenuItemClickListener(this)
|
||||
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
|
||||
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
|
@ -107,6 +110,4 @@ class CardFragment : AbsPlayerFragment() {
|
|||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ 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.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
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.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.*
|
||||
import kotlinx.android.synthetic.main.media_button.*
|
||||
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.image
|
||||
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() {
|
||||
|
||||
|
@ -32,14 +43,15 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||
private var progressViewUpdateHelper: MusicProgressViewUpdateHelper? = null
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
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_card_player_playback_controls, container, false)
|
||||
}
|
||||
|
||||
|
@ -64,6 +76,11 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -116,18 +133,20 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
updatePlayPauseColor()
|
||||
updateProgressTextColor()
|
||||
|
||||
|
||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
||||
color
|
||||
} else {
|
||||
ThemeStore.accentColor(context!!).ripAlpha()
|
||||
}
|
||||
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)
|
||||
|
||||
volumeFragment?.setTintable(colorFinal)
|
||||
|
||||
}
|
||||
|
||||
private fun updatePlayPauseColor() {
|
||||
|
@ -171,7 +190,10 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
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 {
|
||||
override fun playerToolbar(): Toolbar {
|
||||
|
@ -32,7 +33,6 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
|
|||
get() = lastColor
|
||||
private lateinit var playbackControlsFragment: CardBlurPlaybackControlsFragment
|
||||
|
||||
|
||||
override fun onShow() {
|
||||
playbackControlsFragment.show()
|
||||
}
|
||||
|
@ -71,9 +71,10 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
|
|||
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
|
||||
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_card_blur_player, container, false)
|
||||
}
|
||||
|
@ -85,13 +86,14 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
|
|||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardBlurPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment?
|
||||
playbackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardBlurPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment?
|
||||
if (playerAlbumCoverFragment != null) {
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
playerAlbumCoverFragment.removeEffect()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setUpPlayerToolbar() {
|
||||
|
@ -126,21 +128,21 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
|
|||
|
||||
private fun updateBlur() {
|
||||
val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
.getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
|
||||
.getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
|
||||
colorBackground!!.clearColorFilter()
|
||||
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
|
||||
.checkIgnoreMediaStore(requireContext())
|
||||
.generatePalette(requireContext()).build()
|
||||
.transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build())
|
||||
//.centerCrop()
|
||||
//.override(320, 480)
|
||||
.into(object : RetroMusicColoredTarget(colorBackground) {
|
||||
override fun onColorReady(color: Int) {
|
||||
if (color == defaultFooterColor) {
|
||||
colorBackground!!.setColorFilter(color)
|
||||
}
|
||||
.checkIgnoreMediaStore(requireContext())
|
||||
.generatePalette(requireContext()).build()
|
||||
.transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build())
|
||||
//.centerCrop()
|
||||
//.override(320, 480)
|
||||
.into(object : RetroMusicColoredTarget(colorBackground) {
|
||||
override fun onColorReady(color: Int) {
|
||||
if (color == defaultFooterColor) {
|
||||
colorBackground!!.setColorFilter(color)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -150,7 +152,8 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
|
|||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
PreferenceManager.getDefaultSharedPreferences(requireContext()).unregisterOnSharedPreferenceChangeListener(this)
|
||||
PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
|
|
|
@ -14,6 +14,7 @@ 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.extensions.hide
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
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.service.MusicService
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.*
|
||||
import kotlinx.android.synthetic.main.media_button.*
|
||||
|
||||
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.progressSlider
|
||||
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() {
|
||||
|
||||
|
@ -32,14 +40,15 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
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_card_blur_player_playback_controls, container, false)
|
||||
}
|
||||
|
@ -62,7 +71,6 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
volumeFragment?.tintWhiteColor()
|
||||
}
|
||||
|
||||
|
||||
private fun setUpPlayPauseFab() {
|
||||
playPauseButton.apply {
|
||||
TintHelper.setTintAuto(this, Color.WHITE, true)
|
||||
|
@ -78,14 +86,12 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private fun updateProgressTextColor() {
|
||||
val color = MaterialValueHelper.getPrimaryTextColor(context, false)
|
||||
songTotalTime.setTextColor(color)
|
||||
songCurrentProgress.setTextColor(color)
|
||||
}
|
||||
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
progressViewUpdateHelper.start()
|
||||
|
@ -100,6 +106,15 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
updatePlayPauseDrawableState()
|
||||
updateRepeatState()
|
||||
updateShuffleState()
|
||||
updateSong()
|
||||
}
|
||||
|
||||
private fun updateSong() {
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPlayStateChanged() {
|
||||
|
@ -139,7 +154,10 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -167,11 +185,11 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
public override fun show() {
|
||||
playPauseButton!!.animate()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.rotation(360f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.rotation(360f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
}
|
||||
|
||||
public override fun hide() {
|
||||
|
@ -189,14 +207,15 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
MusicPlayerRemote.seekTo(progress)
|
||||
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis)
|
||||
onUpdateProgressViews(
|
||||
MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
progressSlider.max = total
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.widget.SeekBar
|
|||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
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.helper.MusicPlayerRemote
|
||||
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.service.MusicService
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
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.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.shuffleButton
|
||||
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.text
|
||||
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.title
|
||||
|
@ -68,6 +71,12 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
|
@ -104,8 +113,9 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
lastPlaybackControlsColor = color
|
||||
lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color, 0.5f)
|
||||
|
||||
title!!.setTextColor(lastPlaybackControlsColor)
|
||||
text!!.setTextColor(lastDisabledPlaybackControlsColor)
|
||||
title.setTextColor(lastPlaybackControlsColor)
|
||||
text.setTextColor(lastDisabledPlaybackControlsColor)
|
||||
songInfo.setTextColor(lastDisabledPlaybackControlsColor)
|
||||
|
||||
ViewUtil.setProgressDrawable(progressSlider, lastPlaybackControlsColor, true)
|
||||
|
||||
|
|
|
@ -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.helper.MusicPlayerRemote
|
||||
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() {
|
||||
override fun playerToolbar(): Toolbar {
|
||||
|
@ -47,7 +46,11 @@ class FitFragment : AbsPlayerFragment() {
|
|||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
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) {
|
||||
|
@ -61,8 +64,10 @@ class FitFragment : AbsPlayerFragment() {
|
|||
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
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_fit, container, false)
|
||||
}
|
||||
|
@ -74,8 +79,10 @@ class FitFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FitPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment: PlayerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playbackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FitPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
playerAlbumCoverFragment.removeEffect()
|
||||
}
|
||||
|
@ -85,7 +92,11 @@ class FitFragment : AbsPlayerFragment() {
|
|||
inflateMenu(R.menu.menu_player)
|
||||
setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
setOnMenuItemClickListener(this@FitFragment)
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity())
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
this,
|
||||
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
|
||||
requireActivity()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,19 +3,40 @@ package code.name.monkey.retromusic.fragments.player.fit
|
|||
import android.animation.ObjectAnimator
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.animation.*
|
||||
import android.view.LayoutInflater
|
||||
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 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.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||
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.service.MusicService
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
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() {
|
||||
|
||||
|
@ -24,14 +45,15 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
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_fit_playback_controls, container, false)
|
||||
}
|
||||
|
@ -57,6 +79,11 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -118,7 +145,11 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -159,7 +190,10 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -187,11 +221,11 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
public override fun show() {
|
||||
playPauseButton!!.animate()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.rotation(360f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.rotation(360f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
}
|
||||
|
||||
public override fun hide() {
|
||||
|
@ -209,8 +243,10 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
MusicPlayerRemote.seekTo(progress)
|
||||
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis)
|
||||
onUpdateProgressViews(
|
||||
MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -226,16 +262,16 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
pivotY = (height / 2).toFloat()
|
||||
|
||||
animate().setDuration(200)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.scaleX(1.1f)
|
||||
.scaleY(1.1f)
|
||||
.withEndAction {
|
||||
animate().setDuration(200)
|
||||
.setInterpolator(AccelerateInterpolator())
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.alpha(1f).start()
|
||||
}.start()
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.scaleX(1.1f)
|
||||
.scaleY(1.1f)
|
||||
.withEndAction {
|
||||
animate().setDuration(200)
|
||||
.setInterpolator(AccelerateInterpolator())
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.alpha(1f).start()
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,5 +286,4 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ 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.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
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.PreferenceUtil
|
||||
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 {
|
||||
|
||||
|
@ -34,14 +43,15 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
|||
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
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_flat_player_playback_controls, container, false)
|
||||
}
|
||||
|
||||
|
@ -76,13 +86,12 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
|||
|
||||
public override fun show() {
|
||||
playPauseButton!!.animate()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
}
|
||||
|
||||
|
||||
public override fun hide() {
|
||||
playPauseButton!!.apply {
|
||||
scaleX = 0f
|
||||
|
@ -130,6 +139,8 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
|||
title.setTextColor(colorPrimary)
|
||||
text.setBackgroundColor(darkColor)
|
||||
text.setTextColor(colorSecondary)
|
||||
songInfo.setBackgroundColor(darkColor)
|
||||
songInfo.setTextColor(colorSecondary)
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
|
@ -172,7 +183,11 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
|||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setUpProgressSlider() {
|
||||
|
@ -180,8 +195,10 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
|||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
MusicPlayerRemote.seekTo(progress)
|
||||
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis)
|
||||
onUpdateProgressViews(
|
||||
MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -222,9 +239,11 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
|||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@ import code.name.monkey.retromusic.model.Song
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
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() {
|
||||
override fun playerToolbar(): Toolbar {
|
||||
|
@ -34,8 +35,10 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
|||
get() = lastColor
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
flatPlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FlatPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
flatPlaybackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FlatPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
}
|
||||
|
||||
|
@ -43,7 +46,11 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
|||
playerToolbar.inflateMenu(R.menu.menu_player)
|
||||
playerToolbar.setNavigationOnClickListener { _ -> requireActivity().onBackPressed() }
|
||||
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) {
|
||||
|
@ -53,16 +60,20 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
|||
|
||||
valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), android.R.color.transparent, i)
|
||||
valueAnimator!!.addUpdateListener { animation ->
|
||||
val drawable = DrawableGradient(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0)
|
||||
val drawable = DrawableGradient(
|
||||
GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0
|
||||
)
|
||||
colorGradientBackground?.background = drawable
|
||||
|
||||
}
|
||||
valueAnimator!!.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()).start()
|
||||
}
|
||||
|
||||
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_flat_player, container, false)
|
||||
}
|
||||
|
||||
|
@ -70,7 +81,6 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
setUpPlayerToolbar()
|
||||
setUpSubFragments()
|
||||
|
||||
}
|
||||
|
||||
override fun onShow() {
|
||||
|
@ -109,12 +119,10 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onFavoriteToggled() {
|
||||
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
|
||||
override fun toggleFavorite(song: Song) {
|
||||
super.toggleFavorite(song)
|
||||
if (song.id == MusicPlayerRemote.currentSong.id) {
|
||||
|
|
|
@ -21,6 +21,7 @@ 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.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
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.PreferenceUtil
|
||||
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.
|
||||
|
@ -49,13 +62,14 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
|
|||
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_full_player_controls, container, false)
|
||||
}
|
||||
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setUpMusicControllers()
|
||||
|
@ -90,13 +104,12 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
|
|||
|
||||
public override fun show() {
|
||||
playPauseButton!!.animate()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
}
|
||||
|
||||
|
||||
public override fun hide() {
|
||||
playPauseButton.apply {
|
||||
scaleX = 0f
|
||||
|
@ -120,12 +133,16 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
|
|||
ViewUtil.setProgressDrawable(progressSlider, colorFinal, true)
|
||||
|
||||
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()
|
||||
updateShuffleState()
|
||||
updatePrevNextColor()
|
||||
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
|
@ -140,6 +157,11 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
|
|||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
updateIsFavorite()
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
|
@ -199,7 +221,6 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
|
|||
previousButton.setOnClickListener { MusicPlayerRemote.back() }
|
||||
}
|
||||
|
||||
|
||||
private fun updatePrevNextColor() {
|
||||
nextButton.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() {
|
||||
updateRepeatState()
|
||||
}
|
||||
|
@ -231,7 +251,10 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
|
|||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -306,5 +329,4 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), PopupMenu.OnMe
|
|||
fun onFavoriteToggled() {
|
||||
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,10 @@ import code.name.monkey.retromusic.model.lyrics.Lyrics
|
|||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import com.bumptech.glide.Glide
|
||||
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.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -63,7 +66,10 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
lyricsLine1.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()
|
||||
|
||||
lyricsLine1.alpha = 1f
|
||||
|
@ -125,8 +131,10 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
}
|
||||
}
|
||||
|
||||
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_full, container, false)
|
||||
}
|
||||
|
||||
|
@ -152,19 +160,19 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
}
|
||||
|
||||
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.removeSlideEffect()
|
||||
}
|
||||
|
||||
override fun onShow() {
|
||||
|
||||
}
|
||||
|
||||
override fun onHide() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
|
@ -219,13 +227,12 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
val artist = ArtistLoader.getArtist(requireContext(), MusicPlayerRemote.currentSong.artistId)
|
||||
withContext(Dispatchers.Main) {
|
||||
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist)
|
||||
.generatePalette(requireContext())
|
||||
.build()
|
||||
.into(object : RetroMusicColoredTarget(artistImage) {
|
||||
override fun onColorReady(color: Int) {
|
||||
|
||||
}
|
||||
})
|
||||
.generatePalette(requireContext())
|
||||
.build()
|
||||
.into(object : RetroMusicColoredTarget(artistImage) {
|
||||
override fun onColorReady(color: Int) {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ 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.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
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.PreferenceUtil
|
||||
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).
|
||||
|
@ -34,14 +45,15 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
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_material_playback_controls, container, false)
|
||||
}
|
||||
|
||||
|
@ -56,6 +68,12 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -96,10 +114,12 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
|
||||
if (ColorUtil.isColorLight(colorBg)) {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
|
||||
} else {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||
}
|
||||
|
||||
updateRepeatState()
|
||||
|
@ -133,7 +153,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_64dp)
|
||||
} 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() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -189,11 +212,9 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
public override fun show() {
|
||||
|
||||
}
|
||||
|
||||
public override fun hide() {
|
||||
|
||||
}
|
||||
|
||||
override fun setUpProgressSlider() {
|
||||
|
@ -201,8 +222,10 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
MusicPlayerRemote.seekTo(progress)
|
||||
onUpdateProgressViews(MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis)
|
||||
onUpdateProgressViews(
|
||||
MusicPlayerRemote.songProgressMillis,
|
||||
MusicPlayerRemote.songDurationMillis
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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.helper.MusicPlayerRemote
|
||||
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).
|
||||
*/
|
||||
class MaterialFragment : AbsPlayerFragment() {
|
||||
|
||||
override fun playerToolbar(): Toolbar {
|
||||
return playerToolbar
|
||||
}
|
||||
|
@ -52,7 +53,11 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
lastColor = color
|
||||
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) {
|
||||
|
@ -66,8 +71,10 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
toggleFavorite(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
|
||||
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_material, container, false)
|
||||
}
|
||||
|
||||
|
@ -75,12 +82,13 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
setUpSubFragments()
|
||||
setUpPlayerToolbar()
|
||||
|
||||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as MaterialControlsFragment
|
||||
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playbackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as MaterialControlsFragment
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
}
|
||||
|
||||
|
@ -89,7 +97,11 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
inflateMenu(R.menu.menu_player)
|
||||
setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
setOnMenuItemClickListener(this@MaterialFragment)
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity())
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
this,
|
||||
ATHUtil.resolveColor(context, R.attr.colorControlNormal),
|
||||
requireActivity()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package code.name.monkey.retromusic.fragments.player.normal
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.content.SharedPreferences
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Bundle
|
||||
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.TintHelper
|
||||
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.fragments.base.AbsPlayerControlsFragment
|
||||
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.shuffleButton
|
||||
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.text
|
||||
import kotlinx.android.synthetic.main.fragment_player_playback_controls.title
|
||||
|
||||
class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||
class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment(), OnSharedPreferenceChangeListener {
|
||||
|
||||
private var lastPlaybackControlsColor: Int = 0
|
||||
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||
|
@ -51,7 +55,6 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
|
||||
return inflater.inflate(R.layout.fragment_player_playback_controls, container, false)
|
||||
}
|
||||
|
||||
|
@ -67,6 +70,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
showBonceAnimation(playPauseButton)
|
||||
}
|
||||
title.isSelected = true
|
||||
PreferenceUtil.getInstance(requireContext()).registerOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
override fun setDark(color: Int) {
|
||||
|
@ -103,10 +107,16 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
updatePrevNextColor()
|
||||
}
|
||||
|
||||
|
||||
private fun updateSong() {
|
||||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -253,4 +263,16 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
songTotalTime.text = MusicUtil.getReadableDurationString(total.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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,14 @@ import code.name.monkey.retromusic.service.MusicService
|
|||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
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.
|
||||
|
@ -67,37 +74,37 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_peak_control_player, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(
|
||||
view: View,
|
||||
savedInstanceState: Bundle?
|
||||
view: View,
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setUpMusicControllers()
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
|
||||
}
|
||||
|
||||
override fun setDark(color: Int) {
|
||||
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
|
||||
if (ColorUtil.isColorLight(colorBg)) {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
|
||||
} else {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||
}
|
||||
|
||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
||||
|
@ -185,15 +192,16 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
|
|||
previousButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
|
|
|
@ -22,13 +22,19 @@ import androidx.appcompat.widget.Toolbar
|
|||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
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.glide.RetroMusicColoredTarget
|
||||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
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.
|
||||
|
@ -54,7 +60,8 @@ class PeakPlayerFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PeakPlayerControlFragment
|
||||
playbackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PeakPlayerControlFragment
|
||||
}
|
||||
|
||||
private fun setUpPlayerToolbar() {
|
||||
|
@ -62,7 +69,11 @@ class PeakPlayerFragment : AbsPlayerFragment() {
|
|||
inflateMenu(R.menu.menu_player)
|
||||
setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
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 onHide() {
|
||||
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
|
@ -96,24 +105,27 @@ class PeakPlayerFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
override fun onFavoriteToggled() {
|
||||
|
||||
}
|
||||
|
||||
private fun updateSong() {
|
||||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
|
||||
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
|
||||
.checkIgnoreMediaStore(requireContext())
|
||||
.generatePalette(requireContext())
|
||||
.build()
|
||||
.into(object : RetroMusicColoredTarget(playerImage) {
|
||||
override fun onColorReady(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
}
|
||||
})
|
||||
|
||||
.checkIgnoreMediaStore(requireContext())
|
||||
.generatePalette(requireContext())
|
||||
.build()
|
||||
.into(object : RetroMusicColoredTarget(playerImage) {
|
||||
override fun onColorReady(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
|
|
|
@ -16,6 +16,7 @@ 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.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
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.PreferenceUtil
|
||||
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.playPauseButton
|
||||
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.previousButton
|
||||
|
@ -61,6 +63,20 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
updatePlayPauseDrawableState()
|
||||
updateRepeatState()
|
||||
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?) {
|
||||
|
|
|
@ -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.helper.MusicPlayerRemote
|
||||
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() {
|
||||
override fun playerToolbar(): Toolbar {
|
||||
|
@ -24,7 +26,6 @@ class PlainPlayerFragment : AbsPlayerFragment() {
|
|||
override val paletteColor: Int
|
||||
get() = lastColor
|
||||
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
updateSong()
|
||||
|
@ -41,8 +42,10 @@ class PlainPlayerFragment : AbsPlayerFragment() {
|
|||
updateSong()
|
||||
}
|
||||
|
||||
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_plain_player, container, false)
|
||||
}
|
||||
|
||||
|
@ -51,7 +54,11 @@ class PlainPlayerFragment : AbsPlayerFragment() {
|
|||
inflateMenu(R.menu.menu_player)
|
||||
setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
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() {
|
||||
plainPlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlainPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
plainPlaybackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlainPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
}
|
||||
|
||||
|
@ -90,7 +99,11 @@ class PlainPlayerFragment : AbsPlayerFragment() {
|
|||
plainPlaybackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
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() {
|
||||
|
|
|
@ -12,6 +12,7 @@ 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.extensions.hide
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
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.util.MusicUtil
|
||||
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).
|
||||
|
@ -31,7 +40,6 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
|
||||
|
||||
|
||||
override fun onPlayStateChanged() {
|
||||
updatePlayPauseDrawableState()
|
||||
}
|
||||
|
@ -56,7 +64,6 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_simple_controls_fragment, container, false)
|
||||
}
|
||||
|
@ -110,7 +117,10 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -140,21 +150,25 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
songInfo?.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
updateSong()
|
||||
|
||||
}
|
||||
|
||||
public override fun show() {
|
||||
playPauseButton!!.animate()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.rotation(360f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
.scaleX(1f)
|
||||
.scaleY(1f)
|
||||
.rotation(360f)
|
||||
.setInterpolator(DecelerateInterpolator())
|
||||
.start()
|
||||
}
|
||||
|
||||
public override fun hide() {
|
||||
|
@ -168,12 +182,14 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
override fun setUpProgressSlider() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
|
@ -194,7 +210,11 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
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)
|
||||
text.setTextColor(colorFinal)
|
||||
|
||||
|
|
|
@ -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.helper.MusicPlayerRemote
|
||||
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).
|
||||
*/
|
||||
|
||||
class SimplePlayerFragment : AbsPlayerFragment() {
|
||||
|
||||
override fun playerToolbar(): Toolbar {
|
||||
return playerToolbar
|
||||
}
|
||||
|
@ -29,8 +30,10 @@ class SimplePlayerFragment : AbsPlayerFragment() {
|
|||
|
||||
private lateinit var simplePlaybackControlsFragment: SimplePlaybackControlsFragment
|
||||
|
||||
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_player, container, false)
|
||||
}
|
||||
|
@ -42,9 +45,11 @@ class SimplePlayerFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
simplePlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as SimplePlaybackControlsFragment
|
||||
simplePlaybackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as SimplePlaybackControlsFragment
|
||||
}
|
||||
|
||||
override fun onShow() {
|
||||
|
@ -67,7 +72,11 @@ class SimplePlayerFragment : AbsPlayerFragment() {
|
|||
lastColor = color
|
||||
callbacks?.onPaletteColorChanged()
|
||||
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() {
|
||||
|
@ -85,6 +94,10 @@ class SimplePlayerFragment : AbsPlayerFragment() {
|
|||
playerToolbar.inflateMenu(R.menu.menu_player)
|
||||
playerToolbar.setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
playerToolbar.setOnMenuItemClickListener(this)
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity())
|
||||
ToolbarContentTintHelper.colorizeToolbar(
|
||||
playerToolbar,
|
||||
ATHUtil.resolveColor(context, R.attr.colorControlNormal),
|
||||
requireActivity()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,45 +11,44 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
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() {
|
||||
|
||||
override fun show() {
|
||||
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
|
||||
}
|
||||
|
||||
override fun setUpProgressSlider() {
|
||||
|
||||
}
|
||||
|
||||
override fun setDark(color: Int) {
|
||||
|
||||
if (ColorUtil.isColorLight(color)) {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
|
||||
} else {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||
lastDisabledPlaybackControlsColor =
|
||||
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||
}
|
||||
|
||||
updateRepeatState();
|
||||
updateShuffleState();
|
||||
updateRepeatState()
|
||||
updateShuffleState()
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
|
||||
}
|
||||
|
||||
private var lastPlaybackControlsColor: Int = 0
|
||||
private var lastDisabledPlaybackControlsColor: Int = 0
|
||||
|
||||
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?) {
|
||||
|
@ -73,7 +72,10 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
override fun updateShuffleState() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -107,4 +109,5 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun onShuffleModeChanged() {
|
||||
updateShuffleState()
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
|
|||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
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.base.AbsPlayerFragment
|
||||
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.PreferenceUtil
|
||||
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 {
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
|
@ -38,17 +44,17 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
animatorSet.interpolator = LinearInterpolator()
|
||||
animatorSet.start()
|
||||
|
||||
playerSongTotalTime.text = String.format("%s/%s", MusicUtil.getReadableDurationString(total.toLong()),
|
||||
MusicUtil.getReadableDurationString(progress.toLong()))
|
||||
playerSongTotalTime.text = String.format(
|
||||
"%s/%s", MusicUtil.getReadableDurationString(total.toLong()),
|
||||
MusicUtil.getReadableDurationString(progress.toLong())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
override fun playerToolbar(): Toolbar {
|
||||
return playerToolbar
|
||||
}
|
||||
|
||||
override fun onShow() {
|
||||
|
||||
}
|
||||
|
||||
override fun onHide() {
|
||||
|
@ -95,7 +101,7 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
|
||||
title.setTextColor(textColorPrimary)
|
||||
text.setTextColor(textColorPrimaryDisabled)
|
||||
|
||||
songInfo.setTextColor(textColorPrimaryDisabled)
|
||||
playerSongTotalTime.setTextColor(textColorPrimary)
|
||||
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, textColorPrimary, requireActivity())
|
||||
|
@ -127,6 +133,12 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
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? {
|
||||
|
@ -144,10 +156,11 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
}
|
||||
|
||||
private fun setUpSubFragments() {
|
||||
tinyPlaybackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as TinyPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
tinyPlaybackControlsFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as TinyPlaybackControlsFragment
|
||||
val playerAlbumCoverFragment =
|
||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||
playerAlbumCoverFragment.setCallbacks(this)
|
||||
|
||||
}
|
||||
|
||||
private fun setUpPlayerToolbar() {
|
||||
|
@ -174,5 +187,4 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
super.onPlayingMetaChanged()
|
||||
updateSong()
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.content.res.TypedArray;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
@ -57,7 +58,7 @@ public final class PreferenceUtil {
|
|||
|
||||
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";
|
||||
|
||||
|
@ -698,8 +699,8 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false);
|
||||
}
|
||||
|
||||
public boolean getBannerSearchEnable() {
|
||||
return mPreferences.getBoolean(HIDE_HOME_BANNER_SEARCH, false);
|
||||
public boolean isSongInfo() {
|
||||
return mPreferences.getBoolean(EXTRA_SONG_INFO, false);
|
||||
}
|
||||
|
||||
public void setSleepTimerFinishMusic(final boolean value) {
|
||||
|
@ -992,7 +993,7 @@ public final class PreferenceUtil {
|
|||
}
|
||||
|
||||
public void unregisterOnSharedPreferenceChangedListener(
|
||||
SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener) {
|
||||
@NonNull OnSharedPreferenceChangeListener sharedPreferenceChangeListener) {
|
||||
mPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ package code.name.monkey.retromusic.util;
|
|||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
|
@ -36,21 +35,19 @@ import android.view.View;
|
|||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
||||
|
||||
import code.name.monkey.appthemehelper.util.TintHelper;
|
||||
import code.name.monkey.retromusic.App;
|
||||
|
||||
public class RetroUtil {
|
||||
|
||||
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) {
|
||||
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
||||
|
@ -58,25 +55,18 @@ public class RetroUtil {
|
|||
return (int) (dpWidth / 180);
|
||||
}
|
||||
|
||||
public static boolean isTablet() {
|
||||
return App.Companion.getContext().getResources().getConfiguration().smallestScreenWidthDp >= 600;
|
||||
@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;
|
||||
}
|
||||
|
||||
public static boolean isLandscape() {
|
||||
return App.Companion.getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||
}
|
||||
|
||||
@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 float frequencyCount(int frequency) {
|
||||
return (float) (frequency / 1000.0);
|
||||
}
|
||||
|
||||
public static Point getScreenSize(@NonNull Context c) {
|
||||
|
@ -91,6 +81,38 @@ public class RetroUtil {
|
|||
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) {
|
||||
if (activity != null) {
|
||||
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) {
|
||||
switch (PreferenceUtil.getInstance(context).autoDownloadImagesPolicy()) {
|
||||
case "always":
|
||||
|
@ -152,13 +142,26 @@ public class RetroUtil {
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
public static boolean isLandscape() {
|
||||
return App.Companion.getContext().getResources().getConfiguration().orientation
|
||||
== Configuration.ORIENTATION_LANDSCAPE;
|
||||
}
|
||||
|
||||
@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 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) {
|
||||
|
|
|
@ -43,13 +43,30 @@
|
|||
android:paddingEnd="24dp"
|
||||
android:textAppearance="@style/TextViewHeadline5"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
|
||||
app:layout_constraintBottom_toTopOf="@+id/songInfo"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/title"
|
||||
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
|
||||
android:id="@+id/previousButton"
|
||||
android:layout_width="72dp"
|
||||
|
@ -78,7 +95,7 @@
|
|||
android:padding="12dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
|
||||
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"
|
||||
tools:tint="@color/md_black_1000" />
|
||||
|
||||
|
|
|
@ -108,5 +108,4 @@
|
|||
tools:layout="@layout/fragment_adaptive_player_playback_controls" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -152,4 +152,19 @@
|
|||
android:paddingStart="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>
|
||||
|
|
|
@ -13,211 +13,212 @@
|
|||
-->
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/playback_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/playback_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/progressContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="28dp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
<RelativeLayout
|
||||
android:id="@+id/progressContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="28dp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/progressSlider"
|
||||
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_toLeftOf="@id/songTotalTime"
|
||||
android:layout_toRightOf="@id/songCurrentProgress"
|
||||
android:maxHeight="1.5dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:splitTrack="false"
|
||||
tools:ignore="RtlHardcoded,UnusedAttribute"
|
||||
tools:progress="20" />
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/progressSlider"
|
||||
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_toLeftOf="@id/songTotalTime"
|
||||
android:layout_toRightOf="@id/songCurrentProgress"
|
||||
android:maxHeight="1.5dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:splitTrack="false"
|
||||
tools:ignore="RtlHardcoded,UnusedAttribute"
|
||||
tools:progress="20" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songTotalTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center_vertical|right|end"
|
||||
android:paddingRight="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songTotalTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center_vertical|right|end"
|
||||
android:paddingRight="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songCurrentProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:gravity="center_vertical|left|end"
|
||||
android:paddingLeft="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
</RelativeLayout>
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songCurrentProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:gravity="center_vertical|left|end"
|
||||
android:paddingLeft="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/titleContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@+id/text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/progressContainer">
|
||||
<LinearLayout
|
||||
android:id="@+id/titleContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@+id/text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/progressContainer">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:freezesText="true"
|
||||
android:gravity="center"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
</LinearLayout>
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:freezesText="true"
|
||||
android:gravity="center"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
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:textAppearance="@style/TextViewBody2"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playerMediaControllerContainer"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
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:textAppearance="@style/TextViewBody1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/songInfo"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/playerMediaControllerContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layoutDirection="ltr"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text"
|
||||
tools:ignore="ContentDescription,UnusedAttribute"
|
||||
tools:showIn="@layout/fragment_player_playback_controls">
|
||||
<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
|
||||
android:id="@+id/previousButton"
|
||||
android:layout_width="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:padding="16dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/ic_skip_previous_white_24dp"
|
||||
tools:ignore="MissingPrefix"
|
||||
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: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_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/nextButton"
|
||||
android:layout_width="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:padding="16dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/ic_skip_next_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" />
|
||||
|
||||
<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" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/playPauseButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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/shuffleButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="?attr/roundSelector"
|
||||
android:padding="16dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/ic_shuffle_white_24dp"
|
||||
tools:ignore="MissingPrefix"
|
||||
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" />
|
||||
|
||||
<Space
|
||||
android:id="@+id/dummy_fab"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_centerInParent="true" />
|
||||
<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" />
|
||||
|
||||
<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
|
||||
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" />
|
||||
<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>
|
|
@ -71,5 +71,19 @@
|
|||
android:thumbTint="@color/md_white_1000"
|
||||
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>
|
||||
</FrameLayout>
|
|
@ -1,122 +1,133 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/playback_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/playback_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/progress_container_height"
|
||||
android:background="@color/twenty_percent_black_overlay">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/progress_container_height"
|
||||
android:background="@color/twenty_percent_black_overlay">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songCurrentProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:gravity="center_vertical|left|end"
|
||||
android:paddingLeft="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songCurrentProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:gravity="center_vertical|left|end"
|
||||
android:paddingLeft="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songTotalTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center_vertical|right|end"
|
||||
android:paddingRight="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songTotalTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center_vertical|right|end"
|
||||
android:paddingRight="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/progressSlider"
|
||||
style="@style/MusicProgressSlider"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toLeftOf="@id/songTotalTime"
|
||||
android:layout_toRightOf="@id/songCurrentProgress"
|
||||
tools:ignore="RtlHardcoded,UnusedAttribute" />
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/progressSlider"
|
||||
style="@style/MusicProgressSlider"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toLeftOf="@id/songTotalTime"
|
||||
android:layout_toRightOf="@id/songCurrentProgress"
|
||||
tools:ignore="RtlHardcoded,UnusedAttribute" />
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<include layout="@layout/media_button" />
|
||||
<include layout="@layout/media_button" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/volumeFragmentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp" />
|
||||
<FrameLayout
|
||||
android:id="@+id/volumeFragmentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?rectSelector"
|
||||
android:minHeight="72dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UnusedAttribute">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?rectSelector"
|
||||
android:minHeight="72dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:padding="16dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:srcCompat="@drawable/ic_play_circle_filled_white_24dp"
|
||||
app:tint="?colorAccent" />
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:padding="16dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:srcCompat="@drawable/ic_play_circle_filled_white_24dp"
|
||||
app:tint="?colorAccent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_weight="1.0"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="16dp">
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_weight="1.0"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:freezesText="true"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
android:textStyle="bold"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:freezesText="true"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
android:textStyle="bold"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:freezesText="true"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:maxLines="2"
|
||||
android:scrollHorizontally="true"
|
||||
android:textStyle="bold"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:freezesText="true"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:maxLines="2"
|
||||
android:scrollHorizontally="true"
|
||||
android:textStyle="bold"
|
||||
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:maxLines="1"
|
||||
android:paddingTop="4dp"
|
||||
android:textSize="12sp"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -91,7 +91,6 @@
|
|||
tools:text="@tools:sample/lorem/random" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -102,101 +101,101 @@
|
|||
android:maxLines="2"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextViewBody2"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playerMediaControllerContainer"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:textAppearance="@style/TextViewBody1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/songInfo"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/playerMediaControllerContainer"
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songInfo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layoutDirection="ltr"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
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
|
||||
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_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text"
|
||||
tools:ignore="ContentDescription,UnusedAttribute"
|
||||
tools:showIn="@layout/fragment_player_playback_controls">
|
||||
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:layout_centerVertical="true"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_toStartOf="@+id/dummy_fab"
|
||||
android:background="?attr/roundSelector"
|
||||
android:padding="16dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/ic_skip_previous_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" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/nextButton"
|
||||
android:layout_width="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:padding="16dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/ic_skip_next_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: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/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
|
||||
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:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="?attr/roundSelector"
|
||||
android:padding="16dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/ic_shuffle_white_24dp"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:tint="@color/md_black_1000" />
|
||||
|
||||
<Space
|
||||
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>
|
||||
<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"
|
||||
|
|
|
@ -1,103 +1,211 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/playback_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/playback_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingPrefix">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/progress_container_height"
|
||||
android:background="@color/twenty_percent_black_overlay">
|
||||
<RelativeLayout
|
||||
android:id="@+id/progressContainer"
|
||||
android:layout_width="match_parent"
|
||||
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
|
||||
android:id="@+id/songCurrentProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:gravity="center_vertical|left|end"
|
||||
android:paddingLeft="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songCurrentProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:gravity="center_vertical|left|end"
|
||||
android:paddingLeft="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songTotalTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center_vertical|right|end"
|
||||
android:paddingRight="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/songTotalTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center_vertical|right|end"
|
||||
android:paddingRight="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/progressSlider"
|
||||
style="@style/MusicProgressSlider"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toLeftOf="@id/songTotalTime"
|
||||
android:layout_toRightOf="@id/songCurrentProgress"
|
||||
tools:ignore="RtlHardcoded,UnusedAttribute" />
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/progressSlider"
|
||||
style="@style/MusicProgressSlider"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toLeftOf="@id/songTotalTime"
|
||||
android:layout_toRightOf="@id/songCurrentProgress"
|
||||
tools:ignore="RtlHardcoded,UnusedAttribute" />
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/titleContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="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
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:freezesText="true"
|
||||
android:gravity="center"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
android:textStyle="bold"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:freezesText="true"
|
||||
android:gravity="center"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:scrollHorizontally="true"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
android:textStyle="bold"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
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:paddingTop="8dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextViewBody2"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
</LinearLayout>
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="2"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextViewBody1"
|
||||
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
|
||||
android:id="@+id/volumeFragmentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp" />
|
||||
</LinearLayout>
|
||||
<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_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>
|
||||
|
|
|
@ -57,6 +57,27 @@
|
|||
tools:progress="20" />
|
||||
</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
|
||||
android:id="@+id/text"
|
||||
|
@ -66,7 +87,6 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:background="@color/md_red_500"
|
||||
android:ellipsize="end"
|
||||
android:fontFeatureSettings="smcp"
|
||||
android:letterSpacing="0.1"
|
||||
android:maxLines="1"
|
||||
android:padding="4dp"
|
||||
|
@ -79,8 +99,8 @@
|
|||
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/lorem/random" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/songInfo"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/titleContainer"
|
||||
|
@ -113,7 +133,7 @@
|
|||
android:singleLine="true"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
tools:text="@tools:sample/full_names" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
android:orientation="vertical"
|
||||
tools:background="@color/md_grey_800">
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/playerMenu"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -200,8 +199,26 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/songInfo"
|
||||
app:layout_constraintTop_toBottomOf="@+id/playPauseButton"
|
||||
tools:background="@color/md_red_400"
|
||||
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>
|
|
@ -59,7 +59,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
|
|
|
@ -103,13 +103,28 @@
|
|||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextViewBody1"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
|
||||
app:layout_constraintBottom_toTopOf="@+id/songInfo"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
|
||||
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
|
||||
android:id="@+id/repeatButton"
|
||||
|
@ -152,7 +167,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@+id/nextButton"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
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"
|
||||
tools:tint="@color/md_black_1000" />
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@+id/text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageContainer"
|
||||
app:layout_constraintStart_toEndOf="@id/imageContainer"
|
||||
app:layout_constraintTop_toBottomOf="@+id/toolbarContainer">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
|
@ -95,22 +95,37 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textAppearance="@style/TextViewBody2"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/imageContainer"
|
||||
app:layout_constraintBottom_toTopOf="@+id/songInfo"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageContainer"
|
||||
app:layout_constraintStart_toEndOf="@id/imageContainer"
|
||||
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" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/playbackControlsFragmentContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageContainer">
|
||||
app:layout_constraintTop_toBottomOf="@+id/songInfo">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/playbackControlsFragment"
|
||||
|
|
|
@ -139,9 +139,26 @@
|
|||
android:layout_weight="0"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/songInfo"
|
||||
tools:backgroundTint="@color/md_red_400"
|
||||
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>
|
||||
|
||||
|
||||
|
|
|
@ -101,10 +101,26 @@
|
|||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextViewBody1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playPauseButton"
|
||||
app:layout_constraintBottom_toTopOf="@+id/songInfo"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
|
||||
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
|
||||
android:id="@+id/repeatButton"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -145,7 +161,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@+id/nextButton"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
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"
|
||||
tools:tint="@color/md_black_1000" />
|
||||
|
||||
|
|
|
@ -58,15 +58,28 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingStart="16dp"
|
||||
|
||||
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextViewSubtitle2"
|
||||
app:layout_constraintBottom_toTopOf="@+id/playerMediaControllerContainer"
|
||||
app:layout_constraintBottom_toTopOf="@+id/songInfo"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text"
|
||||
tools:layout_editor_absoluteX="16dp"
|
||||
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
|
||||
android:id="@+id/playerMediaControllerContainer"
|
||||
|
@ -76,7 +89,7 @@
|
|||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
|
||||
app:layout_constraintTop_toBottomOf="@+id/songCurrentProgress"
|
||||
app:layout_constraintTop_toBottomOf="@+id/songInfo"
|
||||
tools:ignore="ContentDescription,UnusedAttribute"
|
||||
tools:showIn="@layout/fragment_player_playback_controls">
|
||||
|
||||
|
|
|
@ -51,16 +51,37 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
|
||||
|
||||
android:padding="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextViewHeadline3"
|
||||
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_constraintVertical_bias="0"
|
||||
tools:ignore="MissingPrefix"
|
||||
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
|
||||
android:id="@+id/toolbarContainer"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -33,5 +33,6 @@
|
|||
android:paddingStart="12dp"
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
tools:ignore="MissingPrefix"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
</LinearLayout>
|
|
@ -1,5 +1,5 @@
|
|||
<?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:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -11,73 +11,79 @@
|
|||
tools:ignore="ContentDescription,UnusedAttribute">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
android:id="@+id/previousButton"
|
||||
android:id="@+id/repeatButton"
|
||||
android:layout_width="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: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_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_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
|
||||
android:id="@+id/nextButton"
|
||||
android:layout_width="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: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/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
|
||||
android:id="@+id/shuffleButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="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" />
|
||||
|
||||
<Space
|
||||
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>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -403,6 +403,8 @@
|
|||
|
||||
<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_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="nothing_to_scan">Nothing to scan.</string>
|
||||
<string name="nothing_to_see">Nothing to see</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_title">Filter song duration</string>
|
||||
|
||||
<string name="pref_header_advanced">Advanced</string>
|
||||
<string name="pref_header_album">Album style</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_general">Theme</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_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_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_genre_toggle">Toggle genre tab</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_desaturated_color">Desaturated color</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_general_theme">App theme</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="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>
|
||||
|
|
|
@ -49,10 +49,10 @@
|
|||
android:title="@string/pref_title_home_banner" />
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="hide_home_banner_search"
|
||||
android:key="extra_song_info"
|
||||
android:layout="@layout/list_item_view_switch"
|
||||
android:summary="@string/pref_summary_home_banner"
|
||||
android:title="@string/pref_title_home_banner" />
|
||||
android:summary="@string/pref_summary_extra_song_info"
|
||||
android:title="@string/pref_title_extra_song_info" />
|
||||
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import android.widget.ImageButton;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RadioButton;
|
||||
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -36,55 +35,266 @@ import androidx.appcompat.widget.AppCompatImageView;
|
|||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.appcompat.widget.ToolbarWidgetWrapper;
|
||||
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.util.ArrayList;
|
||||
|
||||
import code.name.monkey.appthemehelper.R;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
|
||||
public final class ToolbarContentTintHelper {
|
||||
|
||||
private ToolbarContentTintHelper() {
|
||||
}
|
||||
public static class InternalToolbarContentTintUtil {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
public static final class SearchViewTintUtil {
|
||||
|
||||
private static void tintMenuItemIcon(int color, MenuItem item) {
|
||||
final Drawable drawable = item.getIcon();
|
||||
if (drawable != null) {
|
||||
final Drawable wrapped = DrawableCompat.wrap(drawable);
|
||||
drawable.mutate();
|
||||
DrawableCompat.setTint(wrapped, color);
|
||||
item.setIcon(drawable);
|
||||
}
|
||||
}
|
||||
public static void setSearchViewContentColor(View searchView, final @ColorInt int color) {
|
||||
if (searchView == null) {
|
||||
return;
|
||||
}
|
||||
final Class<?> cls = searchView.getClass();
|
||||
try {
|
||||
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) {
|
||||
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);
|
||||
Field field = cls.getDeclaredField("mSearchButton");
|
||||
tintImageView(searchView, field, color);
|
||||
field = cls.getDeclaredField("mGoButton");
|
||||
tintImageView(searchView, field, color);
|
||||
field = cls.getDeclaredField("mCloseButton");
|
||||
tintImageView(searchView, field, color);
|
||||
field = cls.getDeclaredField("mVoiceButton");
|
||||
tintImageView(searchView, field, color);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
for (int i = 0; i < toolbar.getChildCount(); i++) {
|
||||
final View backButton = toolbar.getChildAt(i);
|
||||
|
@ -102,7 +312,7 @@ public final class ToolbarContentTintHelper {
|
|||
* @param activity reference to activity needed to register observers
|
||||
*/
|
||||
public static void colorizeToolbar(Toolbar toolbarView, int toolbarIconsColor,
|
||||
Activity activity) {
|
||||
Activity activity) {
|
||||
final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(toolbarIconsColor,
|
||||
PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
|
@ -150,93 +360,64 @@ public final class ToolbarContentTintHelper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It's important to set overflowDescription atribute in styles, so we can grab the reference to
|
||||
* the overflow icon. Check: res/values/styles.xml
|
||||
*/
|
||||
private static void setOverflowButtonColor(final Activity activity,
|
||||
final PorterDuffColorFilter colorFilter) {
|
||||
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<View>();
|
||||
decorView.findViewsWithText(outViews, overflowDescription,
|
||||
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
|
||||
if (outViews.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final ActionMenuView overflowViewParent = (ActionMenuView) outViews.get(0).getParent();
|
||||
overflowViewParent.getOverflowIcon().setColorFilter(colorFilter);
|
||||
removeOnGlobalLayoutListener(decorView, this);
|
||||
}
|
||||
});
|
||||
@Nullable
|
||||
public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) {
|
||||
if (ab == null || !(ab instanceof WindowDecorActionBar)) {
|
||||
return null;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
if (toolbar != null && toolbar.getOverflowIcon() != null) {
|
||||
Drawable bg = DrawableCompat.wrap(toolbar.getOverflowIcon());
|
||||
DrawableCompat.setTint(bg, toolbarIconsColor);
|
||||
}
|
||||
removeOnGlobalLayoutListener(decorView, this);
|
||||
}
|
||||
});
|
||||
public static void handleOnCreateOptionsMenu(
|
||||
@NonNull Context context,
|
||||
@NonNull Toolbar toolbar,
|
||||
@NonNull Menu menu,
|
||||
int toolbarColor) {
|
||||
setToolbarContentColorBasedOnToolbarColor(context, toolbar, menu, toolbarColor);
|
||||
}
|
||||
|
||||
private static void removeOnGlobalLayoutListener(View v,
|
||||
ViewTreeObserver.OnGlobalLayoutListener listener) {
|
||||
v.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
|
||||
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);
|
||||
}
|
||||
|
||||
public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context,
|
||||
Toolbar toolbar,
|
||||
int toolbarColor) {
|
||||
setToolbarContentColorBasedOnToolbarColor(context, toolbar, null, toolbarColor);
|
||||
public static void handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar) {
|
||||
handleOnPrepareOptionsMenu(activity, toolbar, ThemeStore.Companion.accentColor(activity));
|
||||
}
|
||||
|
||||
public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context,
|
||||
Toolbar toolbar,
|
||||
@Nullable Menu menu,
|
||||
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 handleOnPrepareOptionsMenu(Activity activity, Toolbar toolbar,
|
||||
int widgetColor) {
|
||||
InternalToolbarContentTintUtil.applyOverflowMenuTint(activity, toolbar, widgetColor);
|
||||
}
|
||||
|
||||
public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar,
|
||||
final @ColorInt int toolbarContentColor, final @ColorInt int primaryTextColor,
|
||||
final @ColorInt int secondaryTextColor, final @ColorInt int menuWidgetColor) {
|
||||
final @ColorInt int toolbarContentColor, final @ColorInt int primaryTextColor,
|
||||
final @ColorInt int secondaryTextColor, final @ColorInt int menuWidgetColor) {
|
||||
setToolbarContentColor(context, toolbar, null, toolbarContentColor, primaryTextColor,
|
||||
secondaryTextColor, menuWidgetColor);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void setToolbarContentColor(@NonNull Context context,
|
||||
Toolbar toolbar,
|
||||
@Nullable Menu menu,
|
||||
final @ColorInt int toolbarContentColor,
|
||||
final @ColorInt int titleTextColor,
|
||||
final @ColorInt int subtitleTextColor,
|
||||
final @ColorInt int menuWidgetColor) {
|
||||
Toolbar toolbar,
|
||||
@Nullable Menu menu,
|
||||
final @ColorInt int toolbarContentColor,
|
||||
final @ColorInt int titleTextColor,
|
||||
final @ColorInt int subtitleTextColor,
|
||||
final @ColorInt int menuWidgetColor) {
|
||||
if (toolbar == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -258,8 +439,7 @@ public final class ToolbarContentTintHelper {
|
|||
InternalToolbarContentTintUtil.applyOverflowMenuTint(context, toolbar, menuWidgetColor);
|
||||
|
||||
if (context instanceof Activity) {
|
||||
InternalToolbarContentTintUtil
|
||||
.setOverflowButtonColor((Activity) context, toolbarContentColor);
|
||||
InternalToolbarContentTintUtil.setOverflowButtonColor((Activity) context, toolbarContentColor);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -288,7 +468,8 @@ public final class ToolbarContentTintHelper {
|
|||
final Field menuItemClickListener = Toolbar.class
|
||||
.getDeclaredField("mOnMenuItemClickListener");
|
||||
menuItemClickListener.setAccessible(true);
|
||||
Toolbar.OnMenuItemClickListener currentClickListener = (Toolbar.OnMenuItemClickListener) menuItemClickListener
|
||||
Toolbar.OnMenuItemClickListener currentClickListener
|
||||
= (Toolbar.OnMenuItemClickListener) menuItemClickListener
|
||||
.get(toolbar);
|
||||
if (!(currentClickListener instanceof ATHOnMenuItemClickListener)) {
|
||||
final ATHOnMenuItemClickListener newClickListener = new ATHOnMenuItemClickListener(context,
|
||||
|
@ -300,44 +481,38 @@ public final class ToolbarContentTintHelper {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) {
|
||||
if (ab == null || !(ab instanceof WindowDecorActionBar)) {
|
||||
return null;
|
||||
public static void setToolbarContentColorBasedOnToolbarColor(@NonNull Context context,
|
||||
Toolbar toolbar,
|
||||
int toolbarColor) {
|
||||
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
|
||||
|
@ -352,254 +527,90 @@ public final class ToolbarContentTintHelper {
|
|||
@CheckResult
|
||||
@ColorInt
|
||||
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
|
||||
@ColorInt
|
||||
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 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 ToolbarContentTintHelper() {
|
||||
}
|
||||
|
||||
private static class ATHOnMenuItemClickListener implements Toolbar.OnMenuItemClickListener {
|
||||
|
||||
private Context mContext;
|
||||
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);
|
||||
}
|
||||
private static void removeOnGlobalLayoutListener(View v,
|
||||
ViewTreeObserver.OnGlobalLayoutListener listener) {
|
||||
v.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
|
||||
}
|
||||
|
||||
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() {
|
||||
}
|
||||
|
||||
@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));
|
||||
if (toolbar != null && toolbar.getOverflowIcon() != null) {
|
||||
Drawable bg = DrawableCompat.wrap(toolbar.getOverflowIcon());
|
||||
DrawableCompat.setTint(bg, toolbarIconsColor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
removeOnGlobalLayoutListener(decorView, this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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) {
|
||||
/**
|
||||
* It's important to set overflowDescription atribute in styles, so we can grab the reference to
|
||||
* the overflow icon. Check: res/values/styles.xml
|
||||
*/
|
||||
private static void setOverflowButtonColor(final Activity activity,
|
||||
final PorterDuffColorFilter colorFilter) {
|
||||
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<View>();
|
||||
decorView.findViewsWithText(outViews, overflowDescription,
|
||||
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
|
||||
if (outViews.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final Class<?> cls = searchView.getClass();
|
||||
try {
|
||||
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);
|
||||
final ActionMenuView overflowViewParent = (ActionMenuView) outViews.get(0).getParent();
|
||||
overflowViewParent.getOverflowIcon().setColorFilter(colorFilter);
|
||||
removeOnGlobalLayoutListener(decorView, this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Field field = cls.getDeclaredField("mSearchButton");
|
||||
tintImageView(searchView, field, color);
|
||||
field = cls.getDeclaredField("mGoButton");
|
||||
tintImageView(searchView, field, color);
|
||||
field = cls.getDeclaredField("mCloseButton");
|
||||
tintImageView(searchView, field, color);
|
||||
field = cls.getDeclaredField("mVoiceButton");
|
||||
tintImageView(searchView, field, color);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
private static void tintMenuItemIcon(int color, MenuItem item) {
|
||||
final Drawable drawable = item.getIcon();
|
||||
if (drawable != null) {
|
||||
final Drawable wrapped = DrawableCompat.wrap(drawable);
|
||||
drawable.mutate();
|
||||
DrawableCompat.setTint(wrapped, color);
|
||||
item.setIcon(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue