Fix blur and image loading

This commit is contained in:
h4h13 2019-09-21 00:45:00 +05:30
parent dd12d9e34b
commit 07b1559350
22 changed files with 85 additions and 785 deletions

View file

@ -13,8 +13,8 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic" applicationId "code.name.monkey.retromusic"
versionCode 368 versionCode 370
versionName '3.4.000-beta11' versionName '3.4.000-beta12'
multiDexEnabled true multiDexEnabled true

View file

@ -246,17 +246,6 @@
</intent-filter> </intent-filter>
</service> </service>
<!-- Android Auto -->
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<meta-data
android:name="com.google.android.gms.car.application.theme"
android:resource="@style/CarTheme" />
<meta-data
android:name="com.google.android.gms.car.notification.SmallIcon"
android:resource="@drawable/ic_notification" />
<meta-data <meta-data
android:name="android.max_aspect" android:name="android.max_aspect"
android:value="2.1" /> android:value="2.1" />

View file

@ -7,7 +7,7 @@
}, },
{ {
"name": "Lennart Glamann", "name": "Lennart Glamann",
"summary": "Design helper", "summary": "Designer",
"link": "https://t.me/FlixbusLennart", "link": "https://t.me/FlixbusLennart",
"profile_image": "https://i.imgur.com/Q5Nsx1R.jpg" "profile_image": "https://i.imgur.com/Q5Nsx1R.jpg"
}, },

View file

@ -132,7 +132,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
val mimeType = intent.type val mimeType = intent.type
var handled = false var handled = false
println("uri -> $uri") println("uri -> $uri")
/*if (intent.action != null && intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH) { if (intent.action != null && intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH) {
val songs = SearchQueryHelper.getSongs(this, intent.extras!!) val songs = SearchQueryHelper.getSongs(this, intent.extras!!)
if (MusicPlayerRemote.shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) { if (MusicPlayerRemote.shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) {
MusicPlayerRemote.openAndShuffleQueue(songs, true) MusicPlayerRemote.openAndShuffleQueue(songs, true)
@ -140,7 +140,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
MusicPlayerRemote.openQueue(songs, 0, true) MusicPlayerRemote.openQueue(songs, 0, true)
} }
handled = true handled = true
}*/ }
if (uri != null && uri.toString().isNotEmpty()) { if (uri != null && uri.toString().isNotEmpty()) {
MusicPlayerRemote.playFromUri(uri) MusicPlayerRemote.playFromUri(uri)

View file

@ -32,6 +32,7 @@ import code.name.monkey.retromusic.util.RetroUtil
import kotlinx.android.synthetic.main.activity_search.* import kotlinx.android.synthetic.main.activity_search.*
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
import kotlin.collections.ArrayList
class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatcher, SearchView { class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatcher, SearchView {
@Inject @Inject
@ -44,9 +45,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
setDrawUnderStatusBar() setDrawUnderStatusBar()
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_search) setContentView(R.layout.activity_search)
App.musicComponent.inject(this)
App.musicComponent?.inject(this)
searchPresenter.attachView(this) searchPresenter.attachView(this)
setStatusbarColorAuto() setStatusbarColorAuto()
@ -163,11 +162,11 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
} }
override fun showEmptyView() { override fun showEmptyView() {
searchAdapter!!.swapDataSet(ArrayList()) searchAdapter?.swapDataSet(ArrayList())
} }
override fun showData(list: MutableList<Any>) { override fun showData(data: MutableList<Any>) {
searchAdapter!!.swapDataSet(list) searchAdapter?.swapDataSet(data)
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@ -175,10 +174,8 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
when (requestCode) { when (requestCode) {
REQ_CODE_SPEECH_INPUT -> { REQ_CODE_SPEECH_INPUT -> {
if (resultCode == Activity.RESULT_OK && null != data) { if (resultCode == Activity.RESULT_OK && null != data) {
val result: ArrayList<String>? = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
val result = data query = result?.get(0)
.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
query = result[0]
searchView.setText(query, BufferType.EDITABLE) searchView.setText(query, BufferType.EDITABLE)
searchPresenter.search(query!!) searchPresenter.search(query!!)
} }

View file

@ -99,11 +99,11 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), Sliding
} }
private fun setMiniPlayerAlphaProgress(progress: Float) { private fun setMiniPlayerAlphaProgress(progress: Float) {
if (miniPlayerFragment!!.view == null) return if (miniPlayerFragment?.view == null) return
val alpha = 1 - progress val alpha = 1 - progress
miniPlayerFragment!!.view!!.alpha = alpha miniPlayerFragment?.view?.alpha = alpha
// necessary to make the views below clickable // necessary to make the views below clickable
miniPlayerFragment!!.view!!.visibility = if (alpha == 0f) View.GONE else View.VISIBLE miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
bottomNavigationView.translationY = progress * 500 bottomNavigationView.translationY = progress * 500
bottomNavigationView.alpha = alpha bottomNavigationView.alpha = alpha

View file

@ -40,7 +40,7 @@ class ContributorAdapter(
val contributor = contributors[position] val contributor = contributors[position]
holder.bindData(contributor) holder.bindData(contributor)
holder.itemView.setOnClickListener { holder.itemView.setOnClickListener {
openUrl(it!!.context as Activity, contributors[position].link) openUrl(it?.context as Activity, contributors[position].link)
} }
} }
@ -56,10 +56,12 @@ class ContributorAdapter(
internal fun bindData(contributor: Contributor) { internal fun bindData(contributor: Contributor) {
title.text = contributor.name title.text = contributor.name
text.text = contributor.summary text.text = contributor.summary
println(contributor.profileImage)
Glide.with(image.context) Glide.with(image.context)
.load(contributor.profileImage) .load(contributor.profileImage)
.error(R.drawable.ic_account_white_24dp) .error(R.drawable.ic_account_white_24dp)
.placeholder(R.drawable.ic_account_white_24dp) .placeholder(R.drawable.ic_account_white_24dp)
.dontAnimate()
.into(image) .into(image)
} }
} }

View file

@ -1,99 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.auto;
import androidx.annotation.NonNull;
/**
* Created by Beesham Sarendranauth (Beesham)
*/
public class AutoMediaIDHelper {
// Media IDs used on browseable items of MediaBrowser
public static final String MEDIA_ID_EMPTY_ROOT = "__EMPTY_ROOT__";
public static final String MEDIA_ID_ROOT = "__ROOT__";
public static final String MEDIA_ID_MUSICS_BY_SEARCH = "__BY_SEARCH__"; // TODO
public static final String MEDIA_ID_MUSICS_BY_HISTORY = "__BY_HISTORY__";
public static final String MEDIA_ID_MUSICS_BY_TOP_TRACKS = "__BY_TOP_TRACKS__";
public static final String MEDIA_ID_MUSICS_BY_PLAYLIST = "__BY_PLAYLIST__";
public static final String MEDIA_ID_MUSICS_BY_ALBUM = "__BY_ALBUM__";
public static final String MEDIA_ID_MUSICS_BY_ARTIST = "__BY_ARTIST__";
public static final String MEDIA_ID_MUSICS_BY_GENRE = "__BY_GENRE__";
public static final String MEDIA_ID_MUSICS_BY_SHUFFLE = "__BY_SHUFFLE__";
public static final String MEDIA_ID_MUSICS_BY_QUEUE = "__BY_QUEUE__";
private static final String CATEGORY_SEPARATOR = "__/__";
private static final String LEAF_SEPARATOR = "__|__";
/**
* Create a String value that represents a playable or a browsable media.
* <p/>
* Encode the media browseable categories, if any, and the unique music ID, if any,
* into a single String mediaID.
* <p/>
* MediaIDs are of the form <categoryType>__/__<categoryValue>__|__<musicUniqueId>, to make it
* easy to find the category (like genre) that a music was selected from, so we
* can correctly build the playing queue. This is specially useful when
* one music can appear in more than one list, like "by genre -> genre_1"
* and "by artist -> artist_1".
*
* @param mediaID Unique ID for playable items, or null for browseable items.
* @param categories Hierarchy of categories representing this item's browsing parents.
* @return A hierarchy-aware media ID.
*/
public static String createMediaID(String mediaID, String... categories) {
StringBuilder sb = new StringBuilder();
if (categories != null) {
for (int i = 0; i < categories.length; i++) {
if (!isValidCategory(categories[i])) {
throw new IllegalArgumentException("Invalid category: " + categories[i]);
}
sb.append(categories[i]);
if (i < categories.length - 1) {
sb.append(CATEGORY_SEPARATOR);
}
}
}
if (mediaID != null) {
sb.append(LEAF_SEPARATOR).append(mediaID);
}
return sb.toString();
}
public static String extractCategory(@NonNull String mediaID) {
int pos = mediaID.indexOf(LEAF_SEPARATOR);
if (pos >= 0) {
return mediaID.substring(0, pos);
}
return mediaID;
}
public static String extractMusicID(@NonNull String mediaID) {
int pos = mediaID.indexOf(LEAF_SEPARATOR);
if (pos >= 0) {
return mediaID.substring(pos + LEAF_SEPARATOR.length());
}
return null;
}
public static boolean isBrowseable(@NonNull String mediaID) {
return !mediaID.contains(LEAF_SEPARATOR);
}
private static boolean isValidCategory(String category) {
return category == null ||
(!category.contains(CATEGORY_SEPARATOR) && !category.contains(LEAF_SEPARATOR));
}
}

View file

@ -1,480 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.auto;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.AsyncTask;
import android.support.v4.media.MediaBrowserCompat;
import android.support.v4.media.MediaDescriptionCompat;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.AlbumLoader;
import code.name.monkey.retromusic.loaders.ArtistLoader;
import code.name.monkey.retromusic.loaders.GenreLoader;
import code.name.monkey.retromusic.loaders.PlaylistLoader;
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
import code.name.monkey.retromusic.model.Album;
import code.name.monkey.retromusic.model.Artist;
import code.name.monkey.retromusic.model.Genre;
import code.name.monkey.retromusic.model.Playlist;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.providers.MusicPlaybackQueueStore;
import code.name.monkey.retromusic.service.MusicService;
import code.name.monkey.retromusic.util.ImageUtil;
/**
* Created by Beesham Sarendranauth (Beesham)
*/
public class AutoMusicProvider {
private static final String TAG = AutoMusicProvider.class.getName();
private static final String BASE_URI = "androidauto://phonograph";
private static final int PATH_SEGMENT_ID = 0;
private static final int PATH_SEGMENT_TITLE = 1;
private static final int PATH_SEGMENT_ARTIST = 2;
private static final int PATH_SEGMENT_GENRE = 4;
private static final int PATH_SEGMENT_ALBUM_ID = 5;
private WeakReference<MusicService> mMusicService;
// Categorized caches for music data
private ConcurrentMap<Integer, Uri> mMusicListByHistory;
private ConcurrentMap<Integer, Uri> mMusicListByTopTracks;
private ConcurrentMap<Integer, Uri> mMusicListByPlaylist;
private ConcurrentMap<Integer, Uri> mMusicListByAlbum;
private ConcurrentMap<Integer, Uri> mMusicListByArtist;
private ConcurrentMap<Integer, Uri> mMusicListByGenre;
private Uri defaultAlbumArtUri;
private Context mContext;
private volatile State mCurrentState = State.NON_INITIALIZED;
public AutoMusicProvider(Context context) {
mContext = context;
mMusicListByHistory = new ConcurrentSkipListMap<>();
mMusicListByTopTracks = new ConcurrentSkipListMap<>();
mMusicListByPlaylist = new ConcurrentSkipListMap<>();
mMusicListByAlbum = new ConcurrentSkipListMap<>();
mMusicListByArtist = new ConcurrentSkipListMap<>();
mMusicListByGenre = new ConcurrentSkipListMap<>();
defaultAlbumArtUri = Uri.parse("android.resource://" +
mContext.getPackageName() + "/drawable/" +
mContext.getResources().getResourceEntryName(R.drawable.default_album_art));
}
public void setMusicService(MusicService service) {
mMusicService = new WeakReference<>(service);
}
public Iterable<Uri> getHistory() {
if (mCurrentState != State.INITIALIZED) {
return Collections.emptyList();
}
return mMusicListByHistory.values();
}
public Iterable<Uri> getTopTracks() {
if (mCurrentState != State.INITIALIZED) {
return Collections.emptyList();
}
return mMusicListByTopTracks.values();
}
public Iterable<Uri> getPlaylists() {
if (mCurrentState != State.INITIALIZED) {
return Collections.emptyList();
}
return mMusicListByPlaylist.values();
}
public Iterable<Uri> getAlbums() {
if (mCurrentState != State.INITIALIZED) {
return Collections.emptyList();
}
return mMusicListByAlbum.values();
}
public Iterable<Uri> getArtists() {
if (mCurrentState != State.INITIALIZED) {
return Collections.emptyList();
}
return mMusicListByArtist.values();
}
public Iterable<Uri> getGenres() {
if (mCurrentState != State.INITIALIZED) {
return Collections.emptyList();
}
return mMusicListByGenre.values();
}
public Iterable<Uri> getQueue() {
if (mCurrentState != State.INITIALIZED) {
return Collections.emptyList();
}
// Re-built every time since the queue updates often
ConcurrentMap<Integer, Uri> queueList = new ConcurrentSkipListMap<>();
final MusicService service = mMusicService.get();
if (service != null) {
final List<Song> songs = MusicPlaybackQueueStore.getInstance(service).getSavedOriginalPlayingQueue();
for (int i = 0; i < songs.size(); i++) {
final Song s = songs.get(i);
Uri.Builder topTracksData = Uri.parse(BASE_URI).buildUpon();
topTracksData.appendPath(String.valueOf(s.getId()))
.appendPath(s.getTitle())
.appendPath(s.getArtistName())
.appendPath(String.valueOf(s.getAlbumId()));
queueList.putIfAbsent(i, topTracksData.build());
}
}
return queueList.values();
}
public boolean isInitialized() {
return mCurrentState == State.INITIALIZED;
}
/**
* Get the list of music tracks from a server and caches the track information
* for future reference, keying tracks by musicId
*/
public void retrieveMediaAsync(final Callback callback) {
if (mCurrentState == State.INITIALIZED) {
if (callback != null) {
// Nothing to do, execute callback immediately
callback.onMusicCatalogReady(true);
}
return;
}
// Asynchronously load the music catalog in a separate thread
new AsyncTask<Void, Void, State>() {
@Override
protected State doInBackground(Void... params) {
retrieveMedia();
return mCurrentState;
}
@Override
protected void onPostExecute(State current) {
if (callback != null) {
callback.onMusicCatalogReady(current == State.INITIALIZED);
}
}
}.execute();
}
private synchronized void buildListsByHistory() {
ConcurrentMap<Integer, Uri> newMusicListByHistory = new ConcurrentSkipListMap<>();
final List<Song> songs = TopAndRecentlyPlayedTracksLoader.INSTANCE.getRecentlyPlayedTracks(mContext);
for (int i = 0; i < songs.size(); i++) {
final Song s = songs.get(i);
Uri.Builder topTracksData = Uri.parse(BASE_URI).buildUpon();
topTracksData.appendPath(String.valueOf(s.getId()))
.appendPath(s.getTitle())
.appendPath(s.getArtistName())
.appendPath(String.valueOf(s.getAlbumId()));
newMusicListByHistory.putIfAbsent(i, topTracksData.build());
}
mMusicListByHistory = newMusicListByHistory;
}
private synchronized void buildListsByTopTracks() {
ConcurrentMap<Integer, Uri> newMusicListByTopTracks = new ConcurrentHashMap<>();
final List<Song> songs = TopAndRecentlyPlayedTracksLoader.INSTANCE.getTopTracks(mContext);
for (int i = 0; i < songs.size(); i++) {
final Song s = songs.get(i);
Uri.Builder topTracksData = Uri.parse(BASE_URI).buildUpon();
topTracksData.appendPath(String.valueOf(s.getId()))
.appendPath(s.getTitle())
.appendPath(s.getArtistName())
.appendPath(String.valueOf(s.getAlbumId()));
newMusicListByTopTracks.putIfAbsent(i, topTracksData.build());
}
mMusicListByTopTracks = newMusicListByTopTracks;
}
private synchronized void buildListsByPlaylist() {
ConcurrentMap<Integer, Uri> newMusicListByPlaylist = new ConcurrentSkipListMap<>();
final List<Playlist> playlists = PlaylistLoader.INSTANCE.getAllPlaylists(mContext);
for (int i = 0; i < playlists.size(); i++) {
final Playlist p = playlists.get(i);
Uri.Builder playlistData = Uri.parse(BASE_URI).buildUpon();
playlistData.appendPath(String.valueOf(p.id))
.appendPath(p.name);
newMusicListByPlaylist.putIfAbsent(i, playlistData.build());
}
mMusicListByPlaylist = newMusicListByPlaylist;
}
private synchronized void buildListsByAlbum() {
ConcurrentMap<Integer, Uri> newMusicListByAlbum = new ConcurrentSkipListMap<>();
final List<Album> albums = AlbumLoader.INSTANCE.getAllAlbums(mContext);
for (int i = 0; i < albums.size(); i++) {
final Album a = albums.get(i);
Uri.Builder albumData = Uri.parse(BASE_URI).buildUpon();
albumData.appendPath(String.valueOf(a.getId()))
.appendPath(a.getTitle())
.appendPath(a.getArtistName())
.appendPath(String.valueOf(a.getId()));
newMusicListByAlbum.putIfAbsent(i, albumData.build());
}
mMusicListByAlbum = newMusicListByAlbum;
}
private synchronized void buildListsByArtist() {
ConcurrentMap<Integer, Uri> newMusicListByArtist = new ConcurrentSkipListMap<>();
final List<Artist> artists = ArtistLoader.INSTANCE.getAllArtists(mContext);
for (int i = 0; i < artists.size(); i++) {
final Artist a = artists.get(i);
Uri.Builder artistData = Uri.parse(BASE_URI).buildUpon();
artistData.appendPath(String.valueOf(a.getId()))
.appendPath(a.getName())
.appendPath(a.getName());
newMusicListByArtist.putIfAbsent(i, artistData.build());
}
mMusicListByArtist = newMusicListByArtist;
}
private synchronized void buildListsByGenre() {
ConcurrentMap<Integer, Uri> newMusicListByGenre = new ConcurrentSkipListMap<>();
final List<Genre> genres = GenreLoader.INSTANCE.getAllGenres(mContext);
for (int i = 0; i < genres.size(); i++) {
final Genre p = genres.get(i);
Uri.Builder playlistData = Uri.parse(BASE_URI).buildUpon();
playlistData.appendPath(String.valueOf(p.getId()))
.appendPath(p.getName());
newMusicListByGenre.putIfAbsent(i, playlistData.build());
}
mMusicListByGenre = newMusicListByGenre;
}
private synchronized void retrieveMedia() {
try {
if (mCurrentState == State.NON_INITIALIZED) {
mCurrentState = State.INITIALIZING;
buildListsByHistory();
buildListsByTopTracks();
buildListsByPlaylist();
buildListsByAlbum();
buildListsByArtist();
buildListsByGenre();
mCurrentState = State.INITIALIZED;
}
} finally {
if (mCurrentState != State.INITIALIZED) {
// Something bad happened, so we reset state to NON_INITIALIZED to allow
// retries (eg if the network connection is temporary unavailable)
mCurrentState = State.NON_INITIALIZED;
}
}
}
@Nullable
public List<MediaBrowserCompat.MediaItem> getChildren(@NonNull String mediaId,
@NonNull Resources resources) {
List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>();
if (!AutoMediaIDHelper.isBrowseable(mediaId)) {
return mediaItems;
}
switch (mediaId) {
case AutoMediaIDHelper.MEDIA_ID_ROOT:
//mediaItems.add(createBrowsableMediaItem(AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_HISTORY, resources.getString(R.string.history_label), R.drawable.ic_access_time_white_24dp));
//mediaItems.add(createBrowsableMediaItem(AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_TOP_TRACKS, resources.getString(R.string.top_tracks_label), R.drawable.ic_trending_up_white_24dp));
mediaItems.add(
createBrowsableMediaItem(
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ALBUM,
resources.getString(R.string.albums_label),
R.drawable.ic_album_white_24dp
));
mediaItems.add(
createBrowsableMediaItem(
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ARTIST,
resources.getString(R.string.artists_label),
R.drawable.ic_artist_white_24dp
));
mediaItems.add(
createBrowsableMediaItem(
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_PLAYLIST,
resources.getString(R.string.playlists_label),
R.drawable.ic_queue_music_white_24dp
));
mediaItems.add(
createBrowsableMediaItem(
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_GENRE,
resources.getString(R.string.genres_label),
R.drawable.ic_guitar_white_24dp
));
/* mediaItems.add(
createPlayableMediaItem(
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_SHUFFLE,
resources.getString(R.string.action_shuffle_all),
R.drawable.ic_shuffle_white_24dp,
""));*/
//mediaItems.add(createBrowsableMediaItem(AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_QUEUE, resources.getString(R.string.queue_label), R.drawable.ic_playlist_play_white_24dp));
break;
case AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_HISTORY:
for (final Uri uri : getHistory()) {
mediaItems.add(createPlayableMediaItem(mediaId, uri, uri.getPathSegments().get(PATH_SEGMENT_TITLE), uri.getPathSegments().get(PATH_SEGMENT_ARTIST)));
}
break;
case AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_TOP_TRACKS:
for (final Uri uri : getTopTracks()) {
mediaItems.add(createPlayableMediaItem(mediaId, uri, uri.getPathSegments().get(PATH_SEGMENT_TITLE), uri.getPathSegments().get(PATH_SEGMENT_ARTIST)));
}
break;
case AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_PLAYLIST:
for (final Uri uri : getPlaylists()) {
mediaItems.add(createPlayableMediaItem(mediaId, uri, uri.getPathSegments().get(PATH_SEGMENT_TITLE), null));
}
break;
case AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ALBUM:
for (final Uri uri : getAlbums()) {
mediaItems.add(createPlayableMediaItem(mediaId, uri, uri.getPathSegments().get(PATH_SEGMENT_TITLE), uri.getPathSegments().get(PATH_SEGMENT_ARTIST)));
}
break;
case AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ARTIST:
for (final Uri uri : getArtists()) {
mediaItems.add(createPlayableMediaItem(mediaId, uri, uri.getPathSegments().get(PATH_SEGMENT_ARTIST), null));
}
break;
case AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_GENRE:
for (final Uri uri : getGenres()) {
mediaItems.add(createPlayableMediaItem(mediaId, uri, uri.getPathSegments().get(PATH_SEGMENT_TITLE), null));
}
break;
case AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_QUEUE:
for (final Uri uri : getQueue()) {
mediaItems.add(createPlayableMediaItem(mediaId, uri, uri.getPathSegments().get(PATH_SEGMENT_TITLE), uri.getPathSegments().get(PATH_SEGMENT_ARTIST)));
}
break;
}
return mediaItems;
}
private MediaBrowserCompat.MediaItem createBrowsableMediaItem(String mediaId,
String title,
int iconDrawableId) {
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder();
builder.setMediaId(mediaId)
.setTitle(title)
.setIconBitmap(ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(mContext, iconDrawableId, ThemeStore.Companion.textColorSecondary(mContext))));
return new MediaBrowserCompat.MediaItem(builder.build(),
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE);
}
private MediaBrowserCompat.MediaItem createPlayableMediaItem(String mediaId,
Uri musicSelection,
String title,
@Nullable String subtitle) {
return createPlayableMediaItem(mediaId, musicSelection, title, subtitle, null, null);
}
private MediaBrowserCompat.MediaItem createPlayableMediaItem(String mediaId,
Uri musicSelection,
String title,
@Nullable String subtitle,
@Nullable Bitmap albumArt,
@Nullable Resources resources) {
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder();
builder.setMediaId(AutoMediaIDHelper.createMediaID(musicSelection.getPathSegments().get(PATH_SEGMENT_ID), mediaId))
.setTitle(title);
if (subtitle != null) {
builder.setSubtitle(subtitle);
}
if (resources != null) {
if (albumArt != null) {
builder.setIconBitmap(albumArt);
} else {
builder.setIconUri(defaultAlbumArtUri);
}
}
return new MediaBrowserCompat.MediaItem(builder.build(),
MediaBrowserCompat.MediaItem.FLAG_PLAYABLE);
}
private MediaBrowserCompat.MediaItem createPlayableMediaItem(String mediaId,
String title,
int iconDrawableId,
@Nullable String subtitle) {
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder()
.setMediaId(mediaId)
.setTitle(title);
if (subtitle != null) {
builder.setSubtitle(subtitle);
}
return new MediaBrowserCompat.MediaItem(builder.build(),
MediaBrowserCompat.MediaItem.FLAG_PLAYABLE);
}
private enum State {
NON_INITIALIZED, INITIALIZING, INITIALIZED
}
public interface Callback {
void onMusicCatalogReady(boolean success);
}
}

View file

@ -1,15 +0,0 @@
package code.name.monkey.retromusic.auto;
import android.app.UiModeManager;
import android.content.Context;
import android.content.res.Configuration;
public class CarHelper {
private static final String TAG = "CarHelper";
public static boolean isCarUiMode(Context c) {
UiModeManager uiModeManager = (UiModeManager) c.getSystemService(Context.UI_MODE_SERVICE);
return uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR;
}
}

View file

@ -1,5 +1,6 @@
package code.name.monkey.retromusic.fragments.player.blur package code.name.monkey.retromusic.fragments.player.blur
import android.content.SharedPreferences
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -16,10 +17,12 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.glide.SongGlideRequest import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_blur.* import kotlinx.android.synthetic.main.fragment_blur.*
class BlurPlayerFragment : AbsPlayerFragment() { class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }
@ -93,15 +96,15 @@ class BlurPlayerFragment : AbsPlayerFragment() {
private fun updateBlur() { private fun updateBlur() {
val activity = activity ?: return val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
val blurAmount = PreferenceManager.getDefaultSharedPreferences(context).getInt("new_blur_amount", 25) .getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
colorBackground!!.clearColorFilter() colorBackground!!.clearColorFilter()
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong) SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext()) .checkIgnoreMediaStore(requireContext())
.generatePalette(requireContext()).build() .generatePalette(requireContext()).build()
.transform(BlurTransformation.Builder(activity).blurRadius(blurAmount.toFloat()).build()) .transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build())
.centerCrop() //.centerCrop()
.override(320, 480) //.override(320, 480)
.into(object : RetroMusicColoredTarget(colorBackground) { .into(object : RetroMusicColoredTarget(colorBackground) {
override fun onColorReady(color: Int) { override fun onColorReady(color: Int) {
if (color == defaultFooterColor) { if (color == defaultFooterColor) {
@ -120,5 +123,22 @@ class BlurPlayerFragment : AbsPlayerFragment() {
updateIsFavorite() updateIsFavorite()
updateBlur() updateBlur()
} }
override fun onResume() {
super.onResume()
PreferenceManager.getDefaultSharedPreferences(requireContext()).registerOnSharedPreferenceChangeListener(this)
}
override fun onDestroyView() {
super.onDestroyView()
PreferenceManager.getDefaultSharedPreferences(requireContext()).unregisterOnSharedPreferenceChangeListener(this)
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
if (key == PreferenceUtil.NEW_BLUR_AMOUNT) {
updateBlur()
}
}
} }

View file

@ -1,5 +1,6 @@
package code.name.monkey.retromusic.fragments.player.cardblur package code.name.monkey.retromusic.fragments.player.cardblur
import android.content.SharedPreferences
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -17,10 +18,11 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.glide.SongGlideRequest import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_card_blur_player.* import kotlinx.android.synthetic.main.fragment_card_blur_player.*
class CardBlurFragment : AbsPlayerFragment() { class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
override fun playerToolbar(): Toolbar { override fun playerToolbar(): Toolbar {
return playerToolbar return playerToolbar
} }
@ -123,15 +125,15 @@ class CardBlurFragment : AbsPlayerFragment() {
} }
private fun updateBlur() { private fun updateBlur() {
val activity = activity ?: return val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
val blurAmount = PreferenceManager.getDefaultSharedPreferences(context).getInt("new_blur_amount", 25) .getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
colorBackground!!.clearColorFilter() colorBackground!!.clearColorFilter()
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong) SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
.checkIgnoreMediaStore(requireContext()) .checkIgnoreMediaStore(requireContext())
.generatePalette(requireContext()).build() .generatePalette(requireContext()).build()
.transform(BlurTransformation.Builder(activity).blurRadius(blurAmount.toFloat()).build()) .transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build())
.centerCrop() //.centerCrop()
.override(320, 480) //.override(320, 480)
.into(object : RetroMusicColoredTarget(colorBackground) { .into(object : RetroMusicColoredTarget(colorBackground) {
override fun onColorReady(color: Int) { override fun onColorReady(color: Int) {
if (color == defaultFooterColor) { if (color == defaultFooterColor) {
@ -139,11 +141,25 @@ class CardBlurFragment : AbsPlayerFragment() {
} }
} }
}) })
}
override fun onResume() {
super.onResume()
PreferenceManager.getDefaultSharedPreferences(requireContext()).registerOnSharedPreferenceChangeListener(this)
}
override fun onDestroyView() {
super.onDestroyView()
PreferenceManager.getDefaultSharedPreferences(requireContext()).unregisterOnSharedPreferenceChangeListener(this)
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
if (key == PreferenceUtil.NEW_BLUR_AMOUNT) {
updateBlur()
}
} }
companion object { companion object {
fun newInstance(): PlayerFragment { fun newInstance(): PlayerFragment {
return PlayerFragment() return PlayerFragment()
} }

View file

@ -25,7 +25,6 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.menu.SongMenuHelper import code.name.monkey.retromusic.helper.menu.SongMenuHelper
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.lyrics.Lyrics
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
@ -135,7 +134,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), SlidingUpPanelLayout.PanelS
setUpRecyclerView() setUpRecyclerView()
playerSlidingLayout.addPanelSlideListener(this) playerSlidingLayout.addPanelSlideListener(this)
playerSlidingLayout.setAntiDragView(view.findViewById<View>(code.name.monkey.retromusic.R.id.draggableArea)) playerSlidingLayout.setAntiDragView(view.findViewById<View>(R.id.draggableArea))
view.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { view.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() { override fun onGlobalLayout() {

View file

@ -17,16 +17,10 @@ package code.name.monkey.retromusic.service
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.provider.MediaStore
import android.support.v4.media.session.MediaSessionCompat import android.support.v4.media.session.MediaSessionCompat
import android.text.TextUtils
import code.name.monkey.retromusic.auto.AutoMediaIDHelper
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicPlayerRemote.cycleRepeatMode import code.name.monkey.retromusic.helper.MusicPlayerRemote.cycleRepeatMode
import code.name.monkey.retromusic.helper.ShuffleHelper
import code.name.monkey.retromusic.loaders.*
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.providers.MusicPlaybackQueueStore
import code.name.monkey.retromusic.service.MusicService.* import code.name.monkey.retromusic.service.MusicService.*
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import java.util.* import java.util.*
@ -74,93 +68,6 @@ class MediaSessionCallback(private val context: Context,
return MediaButtonIntentReceiver.handleIntent(context, mediaButtonIntent) return MediaButtonIntentReceiver.handleIntent(context, mediaButtonIntent)
} }
override fun onPlayFromMediaId(mediaId: String?, extras: Bundle?) {
super.onPlayFromMediaId(mediaId, extras)
val musicId = mediaId?.let { AutoMediaIDHelper.extractMusicID(it) }
val itemId = musicId?.toInt() ?: -1
val songs = arrayListOf<Song>()
when (val category = mediaId?.let { AutoMediaIDHelper.extractCategory(it) }) {
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ALBUM -> {
val album = AlbumLoader.getAlbum(context, itemId)
album.songs?.let { songs.addAll(it) }
openQueue(songs, 0, true)
}
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_ARTIST -> {
val artist = ArtistLoader.getArtist(context, itemId)
songs.addAll(artist.songs)
openQueue(songs, 0, true)
}
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_PLAYLIST -> {
val playlist = PlaylistLoader.getPlaylist(context, itemId)
songs.addAll(playlist.getSongs(context))
openQueue(songs, 0, true)
}
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_GENRE -> {
songs.addAll(GenreLoader.getSongs(context, itemId))
openQueue(songs, 0, true)
}
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_HISTORY,
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_TOP_TRACKS,
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_QUEUE -> {
val tracks: List<Song>
tracks = when (category) {
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_HISTORY -> TopAndRecentlyPlayedTracksLoader.getRecentlyPlayedTracks(context)
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_TOP_TRACKS -> TopAndRecentlyPlayedTracksLoader.getTopTracks(context)
else -> MusicPlaybackQueueStore.getInstance(context).savedOriginalPlayingQueue
}
songs.addAll(tracks)
var songIndex = MusicUtil.indexOfSongInList(tracks, itemId)
if (songIndex == -1) {
songIndex = 0
}
openQueue(songs, songIndex, true)
}
AutoMediaIDHelper.MEDIA_ID_MUSICS_BY_SHUFFLE -> {
val allSongs = SongLoader.getAllSongs(context)
ShuffleHelper.makeShuffleList(allSongs, -1)
openQueue(allSongs, 0, true)
}
}
}
override fun onPlayFromSearch(query: String?, extras: Bundle?) {
print("query: $query -> extras: ${extras.toString()}")
if (TextUtils.isEmpty(query)) {
if (MusicPlayerRemote.playingQueue.isEmpty()) {
openQueue(SongLoader.getAllSongs(context), 0, true);
} else {
MusicPlayerRemote.resumePlaying()
}
} else {
handlePlayFromSearch(query, extras)
}
}
private fun handlePlayFromSearch(query: String?, extras: Bundle?) {
val mediaFocus: String? = extras?.getString(MediaStore.EXTRA_MEDIA_FOCUS)
println(mediaFocus)
when (mediaFocus) {
MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE -> {
extras.getString(MediaStore.EXTRA_MEDIA_ARTIST)?.let { artist ->
println("Artist name $artist")
}
}
MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE -> {
extras.getString(MediaStore.EXTRA_MEDIA_ALBUM)?.let { album ->
println("Artist name $album")
}
}
MediaStore.Audio.Genres.ENTRY_CONTENT_TYPE -> {
extras.getString(MediaStore.EXTRA_MEDIA_GENRE)?.let { genre ->
println("Artist name $genre")
}
}
}
}
override fun onCustomAction(action: String, extras: Bundle?) { override fun onCustomAction(action: String, extras: Bundle?) {
when (action) { when (action) {
CYCLE_REPEAT -> { CYCLE_REPEAT -> {

View file

@ -15,6 +15,7 @@
package code.name.monkey.retromusic.service; package code.name.monkey.retromusic.service;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.Service;
import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ComponentName; import android.content.ComponentName;
@ -30,7 +31,6 @@ import android.media.AudioManager;
import android.media.audiofx.AudioEffect; import android.media.audiofx.AudioEffect;
import android.os.Binder; import android.os.Binder;
import android.os.Build; import android.os.Build;
import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.os.IBinder; import android.os.IBinder;
@ -38,7 +38,6 @@ import android.os.PowerManager;
import android.os.Process; import android.os.Process;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.v4.media.MediaBrowserCompat;
import android.support.v4.media.MediaMetadataCompat; import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaSessionCompat; import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat; import android.support.v4.media.session.PlaybackStateCompat;
@ -49,7 +48,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.media.MediaBrowserServiceCompat;
import com.bumptech.glide.BitmapRequestBuilder; import com.bumptech.glide.BitmapRequestBuilder;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
@ -66,9 +64,6 @@ import code.name.monkey.retromusic.appwidgets.AppWidgetCard;
import code.name.monkey.retromusic.appwidgets.AppWidgetClassic; import code.name.monkey.retromusic.appwidgets.AppWidgetClassic;
import code.name.monkey.retromusic.appwidgets.AppWidgetSmall; import code.name.monkey.retromusic.appwidgets.AppWidgetSmall;
import code.name.monkey.retromusic.appwidgets.AppWidgetText; import code.name.monkey.retromusic.appwidgets.AppWidgetText;
import code.name.monkey.retromusic.auto.AutoMediaIDHelper;
import code.name.monkey.retromusic.auto.AutoMusicProvider;
import code.name.monkey.retromusic.auto.CarHelper;
import code.name.monkey.retromusic.glide.BlurTransformation; import code.name.monkey.retromusic.glide.BlurTransformation;
import code.name.monkey.retromusic.glide.SongGlideRequest; import code.name.monkey.retromusic.glide.SongGlideRequest;
import code.name.monkey.retromusic.helper.ShuffleHelper; import code.name.monkey.retromusic.helper.ShuffleHelper;
@ -89,7 +84,7 @@ import code.name.monkey.retromusic.util.RetroUtil;
/** /**
* @author Karim Abou Zeid (kabouzeid), Andrew Neal * @author Karim Abou Zeid (kabouzeid), Andrew Neal
*/ */
public class MusicService extends MediaBrowserServiceCompat implements public class MusicService extends Service implements
SharedPreferences.OnSharedPreferenceChangeListener, Playback.PlaybackCallbacks { SharedPreferences.OnSharedPreferenceChangeListener, Playback.PlaybackCallbacks {
public static final String TAG = MusicService.class.getSimpleName(); public static final String TAG = MusicService.class.getSimpleName();
@ -281,7 +276,6 @@ public class MusicService extends MediaBrowserServiceCompat implements
} }
}; };
private PackageValidator mPackageValidator; private PackageValidator mPackageValidator;
private AutoMusicProvider mMusicProvider;
private static String getTrackUri(@NonNull Song song) { private static String getTrackUri(@NonNull Song song) {
return MusicUtil.getSongFileUri(song.getId()).toString(); return MusicUtil.getSongFileUri(song.getId()).toString();
@ -348,7 +342,7 @@ public class MusicService extends MediaBrowserServiceCompat implements
restoreState(); restoreState();
mPackageValidator = new PackageValidator(this, R.xml.allowed_media_browser_callers); mPackageValidator = new PackageValidator(this, R.xml.allowed_media_browser_callers);
mMusicProvider = new AutoMusicProvider(this);
sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_CREATED")); sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_CREATED"));
@ -389,7 +383,7 @@ public class MusicService extends MediaBrowserServiceCompat implements
mediaSession.setCallback(mediasessionCallback); mediaSession.setCallback(mediasessionCallback);
mediaSession.setActive(true); mediaSession.setActive(true);
mediaSession.setMediaButtonReceiver(mediaButtonReceiverPendingIntent); mediaSession.setMediaButtonReceiver(mediaButtonReceiverPendingIntent);
setSessionToken(mediaSession.getSessionToken());
} }
@Override @Override
@ -487,37 +481,9 @@ public class MusicService extends MediaBrowserServiceCompat implements
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
// For Android auto, need to call super, or onGetRoot won't be called.
if (intent != null && "android.media.browse.MediaBrowserService".equals(intent.getAction())) {
return super.onBind(intent);
}
return musicBind; return musicBind;
} }
@Nullable
@Override
public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, @Nullable Bundle rootHints) {
// Check origin to ensure we're not allowing any arbitrary app to browse app contents
if (!mPackageValidator.isKnownCaller(clientPackageName, clientUid)) {
// Request from an untrusted package: return an empty browser root
return new BrowserRoot(AutoMediaIDHelper.MEDIA_ID_EMPTY_ROOT, null);
}
return new BrowserRoot(AutoMediaIDHelper.MEDIA_ID_ROOT, null);
}
@Override
public void onLoadChildren(@NonNull String parentId, @NonNull Result<List<MediaBrowserCompat.MediaItem>> result) {
if (AutoMediaIDHelper.MEDIA_ID_EMPTY_ROOT.equals(parentId)) {
result.sendResult(new ArrayList<>());
} else if (mMusicProvider.isInitialized()) {
result.sendResult(mMusicProvider.getChildren(parentId, getResources()));
} else {
result.detach();
mMusicProvider.retrieveMediaAsync(success -> result.sendResult(mMusicProvider.getChildren(parentId, getResources())));
}
}
@Override @Override
public void onRebind(Intent intent) { public void onRebind(Intent intent) {
@ -744,12 +710,8 @@ public class MusicService extends MediaBrowserServiceCompat implements
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null) .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null)
.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size()); .putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
if (CarHelper.isCarUiMode(this)) {
mediaSession.setMetadata(metaData.build());
}
if (PreferenceUtil.getInstance(this).albumArtOnLockscreen()) {
if (PreferenceUtil.getInstance(this).albumArtOnLockscreen() || CarHelper.isCarUiMode(this)) {
final Point screenSize = RetroUtil.getScreenSize(MusicService.this); final Point screenSize = RetroUtil.getScreenSize(MusicService.this);
final BitmapRequestBuilder<?, Bitmap> request = SongGlideRequest.Builder.from(Glide.with(MusicService.this), song) final BitmapRequestBuilder<?, Bitmap> request = SongGlideRequest.Builder.from(Glide.with(MusicService.this), song)
.checkIgnoreMediaStore(MusicService.this) .checkIgnoreMediaStore(MusicService.this)

View file

@ -66,6 +66,7 @@ public final class PreferenceUtil {
public static final String GAPLESS_PLAYBACK = "gapless_playback"; public static final String GAPLESS_PLAYBACK = "gapless_playback";
public static final String ALBUM_ART_ON_LOCKSCREEN = "album_art_on_lockscreen"; public static final String ALBUM_ART_ON_LOCKSCREEN = "album_art_on_lockscreen";
public static final String BLURRED_ALBUM_ART = "blurred_album_art"; public static final String BLURRED_ALBUM_ART = "blurred_album_art";
public static final String NEW_BLUR_AMOUNT = "new_blur_amount";
public static final String SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_song"; public static final String SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_song";
public static final String TOGGLE_HEADSET = "toggle_headset"; public static final String TOGGLE_HEADSET = "toggle_headset";
public static final String DOMINANT_COLOR = "dominant_color"; public static final String DOMINANT_COLOR = "dominant_color";

View file

@ -32,8 +32,10 @@ import android.widget.TextView
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.retromusic.R
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
object ViewUtil { object ViewUtil {
@ -115,11 +117,10 @@ object ViewUtil {
fun setUpFastScrollRecyclerViewColor(context: Context, fun setUpFastScrollRecyclerViewColor(context: Context,
recyclerView: FastScrollRecyclerView, accentColor: Int) { recyclerView: FastScrollRecyclerView, accentColor: Int) {
recyclerView.setPopupBgColor(accentColor) recyclerView.setPopupBgColor(accentColor)
recyclerView.setPopupTextColor( recyclerView.setPopupTextColor(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(accentColor)))
MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(accentColor)))
recyclerView.setThumbColor(accentColor) recyclerView.setThumbColor(accentColor)
recyclerView.setTrackColor(Color.TRANSPARENT) recyclerView.setTrackColor(Color.TRANSPARENT)
//recyclerView.setTrackColor(ColorUtil.withAlpha(ATHUtil.resolveColor(context, R.attr.colorControlNormal), 0.12f)); recyclerView.setTrackColor(ColorUtil.withAlpha(ATHUtil.resolveColor(context, R.attr.colorControlNormal), 0.12f));
} }
fun convertDpToPixel(dp: Float, resources: Resources): Float { fun convertDpToPixel(dp: Float, resources: Resources): Float {

View file

@ -17,6 +17,7 @@
sothree:umanoFadeColor="#00000000" sothree:umanoFadeColor="#00000000"
sothree:umanoOverlay="true" sothree:umanoOverlay="true"
sothree:umanoPanelHeight="0dp" sothree:umanoPanelHeight="0dp"
sothree:umanoDragView="@id/playerPanel"
sothree:umanoScrollableView="@+id/playerRecyclerView" sothree:umanoScrollableView="@+id/playerRecyclerView"
sothree:umanoShadowHeight="0dp"> sothree:umanoShadowHeight="0dp">

View file

@ -11,6 +11,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"
app:fastScrollPopupBackgroundSize="48dp"
app:fastScrollPopupTextSize="18sp"
app:fastScrollHorizontalThumbDrawable="@drawable/button_background"
android:layoutAnimation="@anim/layout_animation_fall_down" android:layoutAnimation="@anim/layout_animation_fall_down"
android:scrollbars="none" /> android:scrollbars="none" />

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<automotiveApp>
<uses name="media" />
</automotiveApp>

View file

@ -7,7 +7,7 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.android.tools.build:gradle:3.6.0-alpha11'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:bundletool:0.9.0' classpath 'com.android.tools.build:bundletool:0.9.0'
} }

View file

@ -1,6 +1,6 @@
#Sun Feb 24 22:42:48 IST 2019 #Fri Sep 20 00:21:23 IST 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip