update shortcut overrides and other code changes
This commit is contained in:
parent
fc6a71b2c0
commit
d8d5b97d4b
29 changed files with 55 additions and 51 deletions
|
|
@ -149,7 +149,7 @@ public class MainActivity extends AbsMusicContentActivity {
|
||||||
break;
|
break;
|
||||||
case R.id.nav_logout:
|
case R.id.nav_logout:
|
||||||
onLogout = true;
|
onLogout = true;
|
||||||
ConfirmLogoutDialog.create().show(getSupportFragmentManager(), "CONFIRM_LOGOUT_DIALOG");
|
ConfirmLogoutDialog.create().show(getSupportFragmentManager(), ConfirmLogoutDialog.TAG);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,8 @@ public abstract class AbsMusicPanelActivity extends AbsMusicServiceActivity impl
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPanelExpanded(View panel) {
|
public void onPanelExpanded(View panel) {
|
||||||
// setting fragments values
|
|
||||||
int playerFragmentColor = playerFragment.getPaletteColor();
|
int playerFragmentColor = playerFragment.getPaletteColor();
|
||||||
|
|
||||||
super.setLightStatusBar(false);
|
super.setLightStatusBar(false);
|
||||||
super.setTaskDescriptionColor(playerFragmentColor);
|
super.setTaskDescriptionColor(playerFragmentColor);
|
||||||
super.setNavigationBarColor(playerFragmentColor);
|
super.setNavigationBarColor(playerFragmentColor);
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ public abstract class AbsMusicServiceActivity extends AbsBaseActivity implements
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(final Context context, @NonNull final Intent intent) {
|
public void onReceive(final Context context, @NonNull final Intent intent) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
AbsMusicServiceActivity activity = reference.get();
|
final AbsMusicServiceActivity activity = reference.get();
|
||||||
if (activity != null && action != null) {
|
if (activity != null && action != null) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case MusicService.META_CHANGED:
|
case MusicService.META_CHANGED:
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public abstract class AbsThemeActivity extends ATHToolbarActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatusBarColorAuto() {
|
public void setStatusBarColorAuto() {
|
||||||
// we don't want to use status bar color because we are darkening the color on our own to support KitKat
|
// ignore status bar color because we are darkening the color on our own to support KitKat
|
||||||
setStatusBarColor(ThemeStore.primaryColor(this));
|
setStatusBarColor(ThemeStore.primaryColor(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import androidx.annotation.LayoutRes;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.dkanada.gramophone.R;
|
||||||
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
|
import com.dkanada.gramophone.adapter.base.MediaEntryViewHolder;
|
||||||
import com.dkanada.gramophone.glide.CustomGlideRequest;
|
import com.dkanada.gramophone.glide.CustomGlideRequest;
|
||||||
import com.dkanada.gramophone.glide.CustomPaletteTarget;
|
import com.dkanada.gramophone.glide.CustomPaletteTarget;
|
||||||
|
|
@ -24,12 +24,9 @@ public class GenreAdapter extends RecyclerView.Adapter<GenreAdapter.ViewHolder>
|
||||||
private final AppCompatActivity activity;
|
private final AppCompatActivity activity;
|
||||||
private List<Genre> dataSet;
|
private List<Genre> dataSet;
|
||||||
|
|
||||||
private int itemLayoutRes;
|
public GenreAdapter(@NonNull AppCompatActivity activity, List<Genre> dataSet) {
|
||||||
|
|
||||||
public GenreAdapter(@NonNull AppCompatActivity activity, List<Genre> dataSet, @LayoutRes int itemLayoutRes) {
|
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.dataSet = dataSet;
|
this.dataSet = dataSet;
|
||||||
this.itemLayoutRes = itemLayoutRes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Genre> getDataSet() {
|
public List<Genre> getDataSet() {
|
||||||
|
|
@ -49,7 +46,7 @@ public class GenreAdapter extends RecyclerView.Adapter<GenreAdapter.ViewHolder>
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false);
|
View view = LayoutInflater.from(activity).inflate(R.layout.item_list_single_row, parent, false);
|
||||||
|
|
||||||
return new ViewHolder(view);
|
return new ViewHolder(view);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
||||||
protected void onMultipleItemAction(@NonNull MenuItem menuItem, @NonNull List<Playlist> selection) {
|
protected void onMultipleItemAction(@NonNull MenuItem menuItem, @NonNull List<Playlist> selection) {
|
||||||
switch (menuItem.getItemId()) {
|
switch (menuItem.getItemId()) {
|
||||||
case R.id.action_delete_playlist:
|
case R.id.action_delete_playlist:
|
||||||
DeletePlaylistDialog.create(selection).show(activity.getSupportFragmentManager(), "DELETE_PLAYLIST");
|
DeletePlaylistDialog.create(selection).show(activity.getSupportFragmentManager(), DeletePlaylistDialog.TAG);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.getItemId());
|
SongsMenuHelper.handleMenuClick(activity, getSongList(selection), menuItem.getItemId());
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setColors(int color, ViewHolder holder) {
|
protected void setColors(int color, ViewHolder holder) {
|
||||||
if (holder.itemView != null) {
|
|
||||||
CardView card = (CardView) holder.itemView;
|
CardView card = (CardView) holder.itemView;
|
||||||
card.setCardBackgroundColor(color);
|
card.setCardBackgroundColor(color);
|
||||||
|
|
||||||
if (holder.title != null) {
|
if (holder.title != null) {
|
||||||
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +45,6 @@ public class HorizontalAlbumAdapter extends AlbumAdapter {
|
||||||
holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadAlbumCover(Album album, final ViewHolder holder) {
|
protected void loadAlbumCover(Album album, final ViewHolder holder) {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ import com.dkanada.gramophone.util.NavigationUtil;
|
||||||
import com.dkanada.gramophone.util.PreferenceUtil;
|
import com.dkanada.gramophone.util.PreferenceUtil;
|
||||||
|
|
||||||
public class ConfirmLogoutDialog extends DialogFragment {
|
public class ConfirmLogoutDialog extends DialogFragment {
|
||||||
|
public static final String TAG = ConfirmLogoutDialog.class.getSimpleName();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static ConfirmLogoutDialog create() {
|
public static ConfirmLogoutDialog create() {
|
||||||
return new ConfirmLogoutDialog();
|
return new ConfirmLogoutDialog();
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DeletePlaylistDialog extends DialogFragment {
|
public class DeletePlaylistDialog extends DialogFragment {
|
||||||
|
public static final String TAG = DeletePlaylistDialog.class.getSimpleName();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static DeletePlaylistDialog create(Playlist playlist) {
|
public static DeletePlaylistDialog create(Playlist playlist) {
|
||||||
List<Playlist> list = new ArrayList<>();
|
List<Playlist> list = new ArrayList<>();
|
||||||
|
|
@ -52,10 +54,7 @@ public class DeletePlaylistDialog extends DialogFragment {
|
||||||
.content(content)
|
.content(content)
|
||||||
.positiveText(R.string.delete_action)
|
.positiveText(R.string.delete_action)
|
||||||
.negativeText(android.R.string.cancel)
|
.negativeText(android.R.string.cancel)
|
||||||
.onPositive((dialog, which) -> {
|
.onPositive((dialog, which) -> PlaylistUtil.deletePlaylist(playlists))
|
||||||
if (getActivity() == null) return;
|
|
||||||
PlaylistUtil.deletePlaylist(playlists);
|
|
||||||
})
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ import com.dkanada.gramophone.model.Song;
|
||||||
import com.dkanada.gramophone.util.MusicUtil;
|
import com.dkanada.gramophone.util.MusicUtil;
|
||||||
|
|
||||||
public class SongDetailDialog extends DialogFragment {
|
public class SongDetailDialog extends DialogFragment {
|
||||||
|
public static final String TAG = SongDetailDialog.class.getSimpleName();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static SongDetailDialog create(Song song) {
|
public static SongDetailDialog create(Song song) {
|
||||||
SongDetailDialog dialog = new SongDetailDialog();
|
SongDetailDialog dialog = new SongDetailDialog();
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ import com.dkanada.gramophone.model.Song;
|
||||||
import com.dkanada.gramophone.util.MusicUtil;
|
import com.dkanada.gramophone.util.MusicUtil;
|
||||||
|
|
||||||
public class SongShareDialog extends DialogFragment {
|
public class SongShareDialog extends DialogFragment {
|
||||||
|
public static final String TAG = SongShareDialog.class.getSimpleName();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static SongShareDialog create(final Song song) {
|
public static SongShareDialog create(final Song song) {
|
||||||
final SongShareDialog dialog = new SongShareDialog();
|
final SongShareDialog dialog = new SongShareDialog();
|
||||||
|
|
|
||||||
|
|
@ -16,28 +16,28 @@ public class AbsMusicServiceFragment extends Fragment implements MusicServiceEve
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(@NonNull Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
try {
|
|
||||||
activity = (AbsMusicServiceActivity) context;
|
activity = (AbsMusicServiceActivity) context;
|
||||||
} catch (ClassCastException e) {
|
|
||||||
throw new RuntimeException(context.getClass().getSimpleName() + " must be an instance of " + AbsMusicServiceActivity.class.getSimpleName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDetach() {
|
public void onDetach() {
|
||||||
super.onDetach();
|
super.onDetach();
|
||||||
|
|
||||||
activity = null;
|
activity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
activity.addMusicServiceEventListener(this);
|
activity.addMusicServiceEventListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
|
||||||
activity.removeMusicServiceEventListener(this);
|
activity.removeMusicServiceEventListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ public class GenresFragment extends AbsLibraryPagerRecyclerViewFragment<GenreAda
|
||||||
@Override
|
@Override
|
||||||
protected GenreAdapter createAdapter() {
|
protected GenreAdapter createAdapter() {
|
||||||
List<Genre> dataSet = getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
|
List<Genre> dataSet = getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
|
||||||
return new GenreAdapter(getLibraryFragment().getMainActivity(), dataSet, R.layout.item_list_single_row);
|
return new GenreAdapter(getLibraryFragment().getMainActivity(), dataSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public abstract class AbsPlayerFragment extends AbsMusicServiceFragment implemen
|
||||||
toggleFavorite(song);
|
toggleFavorite(song);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_share:
|
case R.id.action_share:
|
||||||
SongShareDialog.create(song).show(getParentFragmentManager(), "SHARE_SONG");
|
SongShareDialog.create(song).show(getParentFragmentManager(), SongShareDialog.TAG);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_add_to_playlist:
|
case R.id.action_add_to_playlist:
|
||||||
AddToPlaylistDialog.create(song).show(getParentFragmentManager(), "ADD_PLAYLIST");
|
AddToPlaylistDialog.create(song).show(getParentFragmentManager(), "ADD_PLAYLIST");
|
||||||
|
|
@ -67,7 +67,7 @@ public abstract class AbsPlayerFragment extends AbsMusicServiceFragment implemen
|
||||||
CreatePlaylistDialog.create(MusicPlayerRemote.getPlayingQueue()).show(getParentFragmentManager(), "ADD_TO_PLAYLIST");
|
CreatePlaylistDialog.create(MusicPlayerRemote.getPlayingQueue()).show(getParentFragmentManager(), "ADD_TO_PLAYLIST");
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_details:
|
case R.id.action_details:
|
||||||
SongDetailDialog.create(song).show(getParentFragmentManager(), "SONG_DETAIL");
|
SongDetailDialog.create(song).show(getParentFragmentManager(), SongDetailDialog.TAG);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_go_to_album:
|
case R.id.action_go_to_album:
|
||||||
NavigationUtil.startAlbum(requireActivity(), new Album(song));
|
NavigationUtil.startAlbum(requireActivity(), new Album(song));
|
||||||
|
|
|
||||||
|
|
@ -419,7 +419,7 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
MusicPlayerRemote.removeFromQueue(MusicPlayerRemote.getPosition());
|
MusicPlayerRemote.removeFromQueue(MusicPlayerRemote.getPosition());
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_share:
|
case R.id.action_share:
|
||||||
SongShareDialog.create(getSong()).show(fragment.getParentFragmentManager(), "SONG_SHARE_DIALOG");
|
SongShareDialog.create(getSong()).show(fragment.getParentFragmentManager(), SongShareDialog.TAG);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -406,7 +406,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
MusicPlayerRemote.removeFromQueue(MusicPlayerRemote.getPosition());
|
MusicPlayerRemote.removeFromQueue(MusicPlayerRemote.getPosition());
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_share:
|
case R.id.action_share:
|
||||||
SongShareDialog.create(getSong()).show(fragment.getParentFragmentManager(), "SONG_SHARE_DIALOG");
|
SongShareDialog.create(getSong()).show(fragment.getParentFragmentManager(), SongShareDialog.TAG);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ public class MusicProgressViewUpdateHelper extends Handler {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(@NonNull Message msg) {
|
public void handleMessage(@NonNull Message msg) {
|
||||||
super.handleMessage(msg);
|
super.handleMessage(msg);
|
||||||
|
|
||||||
if (msg.what == CMD_REFRESH_PROGRESS_VIEWS) {
|
if (msg.what == CMD_REFRESH_PROGRESS_VIEWS) {
|
||||||
queueNextRefresh(refreshProgressViews());
|
queueNextRefresh(refreshProgressViews());
|
||||||
}
|
}
|
||||||
|
|
@ -40,6 +41,7 @@ public class MusicProgressViewUpdateHelper extends Handler {
|
||||||
private int refreshProgressViews() {
|
private int refreshProgressViews() {
|
||||||
final int progressMillis = MusicPlayerRemote.getSongProgressMillis();
|
final int progressMillis = MusicPlayerRemote.getSongProgressMillis();
|
||||||
final int totalMillis = MusicPlayerRemote.getSongDurationMillis();
|
final int totalMillis = MusicPlayerRemote.getSongDurationMillis();
|
||||||
|
final int remainingMillis = intervalPlaying - progressMillis % intervalPlaying;
|
||||||
|
|
||||||
callback.onUpdateProgressViews(progressMillis, totalMillis);
|
callback.onUpdateProgressViews(progressMillis, totalMillis);
|
||||||
|
|
||||||
|
|
@ -47,8 +49,6 @@ public class MusicProgressViewUpdateHelper extends Handler {
|
||||||
return intervalPaused;
|
return intervalPaused;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int remainingMillis = intervalPlaying - progressMillis % intervalPlaying;
|
|
||||||
|
|
||||||
return Math.max(MIN_INTERVAL, remainingMillis);
|
return Math.max(MIN_INTERVAL, remainingMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ public class ShuffleHelper {
|
||||||
|
|
||||||
if (current >= 0) {
|
if (current >= 0) {
|
||||||
Song song = listToShuffle.remove(current);
|
Song song = listToShuffle.remove(current);
|
||||||
|
|
||||||
Collections.shuffle(listToShuffle);
|
Collections.shuffle(listToShuffle);
|
||||||
listToShuffle.add(0, song);
|
listToShuffle.add(0, song);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
|
||||||
@Override
|
@Override
|
||||||
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
||||||
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
|
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
|
||||||
|
|
||||||
return makeMovementFlags(dragFlags, 0);
|
return makeMovementFlags(dragFlags, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class PlaylistMenuHelper {
|
||||||
RenamePlaylistDialog.create(playlist).show(activity.getSupportFragmentManager(), "RENAME_PLAYLIST");
|
RenamePlaylistDialog.create(playlist).show(activity.getSupportFragmentManager(), "RENAME_PLAYLIST");
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_delete_playlist:
|
case R.id.action_delete_playlist:
|
||||||
DeletePlaylistDialog.create(playlist).show(activity.getSupportFragmentManager(), "DELETE_PLAYLIST");
|
DeletePlaylistDialog.create(playlist).show(activity.getSupportFragmentManager(), DeletePlaylistDialog.TAG);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.dkanada.gramophone.helper.menu;
|
package com.dkanada.gramophone.helper.menu;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
@ -11,11 +10,11 @@ import android.widget.PopupMenu;
|
||||||
import com.dkanada.gramophone.R;
|
import com.dkanada.gramophone.R;
|
||||||
import com.dkanada.gramophone.dialogs.AddToPlaylistDialog;
|
import com.dkanada.gramophone.dialogs.AddToPlaylistDialog;
|
||||||
import com.dkanada.gramophone.dialogs.SongDetailDialog;
|
import com.dkanada.gramophone.dialogs.SongDetailDialog;
|
||||||
|
import com.dkanada.gramophone.dialogs.SongShareDialog;
|
||||||
import com.dkanada.gramophone.helper.MusicPlayerRemote;
|
import com.dkanada.gramophone.helper.MusicPlayerRemote;
|
||||||
import com.dkanada.gramophone.model.Album;
|
import com.dkanada.gramophone.model.Album;
|
||||||
import com.dkanada.gramophone.model.Artist;
|
import com.dkanada.gramophone.model.Artist;
|
||||||
import com.dkanada.gramophone.model.Song;
|
import com.dkanada.gramophone.model.Song;
|
||||||
import com.dkanada.gramophone.util.MusicUtil;
|
|
||||||
import com.dkanada.gramophone.util.NavigationUtil;
|
import com.dkanada.gramophone.util.NavigationUtil;
|
||||||
|
|
||||||
public class SongMenuHelper {
|
public class SongMenuHelper {
|
||||||
|
|
@ -24,7 +23,7 @@ public class SongMenuHelper {
|
||||||
public static boolean handleMenuClick(@NonNull FragmentActivity activity, @NonNull Song song, int menuItemId) {
|
public static boolean handleMenuClick(@NonNull FragmentActivity activity, @NonNull Song song, int menuItemId) {
|
||||||
switch (menuItemId) {
|
switch (menuItemId) {
|
||||||
case R.id.action_share:
|
case R.id.action_share:
|
||||||
activity.startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, activity), null));
|
SongShareDialog.create(song).show(activity.getSupportFragmentManager(), SongShareDialog.TAG);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_add_to_playlist:
|
case R.id.action_add_to_playlist:
|
||||||
AddToPlaylistDialog.create(song).show(activity.getSupportFragmentManager(), "ADD_PLAYLIST");
|
AddToPlaylistDialog.create(song).show(activity.getSupportFragmentManager(), "ADD_PLAYLIST");
|
||||||
|
|
@ -36,7 +35,7 @@ public class SongMenuHelper {
|
||||||
MusicPlayerRemote.enqueue(song);
|
MusicPlayerRemote.enqueue(song);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_details:
|
case R.id.action_details:
|
||||||
SongDetailDialog.create(song).show(activity.getSupportFragmentManager(), "SONG_DETAILS");
|
SongDetailDialog.create(song).show(activity.getSupportFragmentManager(), SongDetailDialog.TAG);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_go_to_album:
|
case R.id.action_go_to_album:
|
||||||
NavigationUtil.startAlbum(activity, new Album(song));
|
NavigationUtil.startAlbum(activity, new Album(song));
|
||||||
|
|
@ -62,6 +61,7 @@ public class SongMenuHelper {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
PopupMenu popupMenu = new PopupMenu(activity, v);
|
PopupMenu popupMenu = new PopupMenu(activity, v);
|
||||||
|
|
||||||
popupMenu.inflate(getMenuRes());
|
popupMenu.inflate(getMenuRes());
|
||||||
popupMenu.setOnMenuItemClickListener(this);
|
popupMenu.setOnMenuItemClickListener(this);
|
||||||
popupMenu.show();
|
popupMenu.show();
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public abstract class PlayingNotification {
|
||||||
|
|
||||||
if (newNotifyMode == NOTIFY_MODE_FOREGROUND) {
|
if (newNotifyMode == NOTIFY_MODE_FOREGROUND) {
|
||||||
service.startForeground(NOTIFICATION_ID, notification);
|
service.startForeground(NOTIFICATION_ID, notification);
|
||||||
} else if (newNotifyMode == NOTIFY_MODE_BACKGROUND) {
|
} else {
|
||||||
notificationManager.notify(NOTIFICATION_ID, notification);
|
notificationManager.notify(NOTIFICATION_ID, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ public class PlayingNotificationNougat extends PlayingNotification {
|
||||||
stopped = false;
|
stopped = false;
|
||||||
|
|
||||||
final Song song = service.getCurrentSong();
|
final Song song = service.getCurrentSong();
|
||||||
|
|
||||||
final boolean isPlaying = service.isPlaying();
|
final boolean isPlaying = service.isPlaying();
|
||||||
|
|
||||||
final int playButtonResId = isPlaying
|
final int playButtonResId = isPlaying
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ import com.dkanada.gramophone.model.Song;
|
||||||
import com.dkanada.gramophone.util.MusicUtil;
|
import com.dkanada.gramophone.util.MusicUtil;
|
||||||
import com.dkanada.gramophone.util.PreferenceUtil;
|
import com.dkanada.gramophone.util.PreferenceUtil;
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
|
||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
|
import com.google.android.exoplayer2.Player.EventListener;
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
import com.google.android.exoplayer2.database.ExoDatabaseProvider;
|
import com.google.android.exoplayer2.database.ExoDatabaseProvider;
|
||||||
|
|
@ -35,7 +35,7 @@ public class LocalPlayer implements Playback {
|
||||||
|
|
||||||
private PlaybackCallbacks callbacks;
|
private PlaybackCallbacks callbacks;
|
||||||
|
|
||||||
private final ExoPlayer.EventListener eventListener = new ExoPlayer.EventListener() {
|
private final EventListener eventListener = new EventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
|
public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
|
||||||
Log.i(TAG, String.format("onPlayWhenReadyChanged: %b %d", playWhenReady, reason));
|
Log.i(TAG, String.format("onPlayWhenReadyChanged: %b %d", playWhenReady, reason));
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ public class NetworkReceiver extends BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
|
||||||
|
|
||||||
// network info will be null in airplane mode
|
// network info will be null in airplane mode
|
||||||
if (netInfo != null && netInfo.isConnected()) {
|
if (networkInfo != null && networkInfo.isConnected()) {
|
||||||
context.sendBroadcast(new Intent(LoginService.STATE_ONLINE));
|
context.sendBroadcast(new Intent(LoginService.STATE_ONLINE));
|
||||||
} else {
|
} else {
|
||||||
context.sendBroadcast(new Intent(LoginService.STATE_OFFLINE));
|
context.sendBroadcast(new Intent(LoginService.STATE_OFFLINE));
|
||||||
|
|
|
||||||
|
|
@ -18,17 +18,16 @@ import com.dkanada.gramophone.util.PreferenceUtil;
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
public final class AppShortcutIconGenerator {
|
public final class AppShortcutIconGenerator {
|
||||||
|
|
||||||
public static Icon generateThemedIcon(Context context, int iconId) {
|
public static Icon generateThemedIcon(Context context, int iconId) {
|
||||||
if (PreferenceUtil.getInstance(context).getColoredShortcuts()) {
|
if (PreferenceUtil.getInstance(context).getColoredShortcuts()) {
|
||||||
return generateUserThemedIcon(context, iconId).toIcon();
|
return generateUserThemedIcon(context, iconId).toIcon(context);
|
||||||
} else {
|
} else {
|
||||||
return generateDefaultThemedIcon(context, iconId).toIcon();
|
return generateDefaultThemedIcon(context, iconId).toIcon(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IconCompat generateDefaultThemedIcon(Context context, int iconId) {
|
private static IconCompat generateDefaultThemedIcon(Context context, int iconId) {
|
||||||
// Return an Icon of iconId with default colors
|
// return icon of iconId with default colors
|
||||||
return generateThemedIcon(context, iconId,
|
return generateThemedIcon(context, iconId,
|
||||||
context.getColor(R.color.app_shortcut_default_foreground),
|
context.getColor(R.color.app_shortcut_default_foreground),
|
||||||
context.getColor(R.color.app_shortcut_default_background)
|
context.getColor(R.color.app_shortcut_default_background)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public final class FrequentShortcutType extends BaseShortcutType {
|
||||||
return PREFIX + ".frequent";
|
return PREFIX + ".frequent";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ShortcutInfo getShortcutInfo() {
|
public ShortcutInfo getShortcutInfo() {
|
||||||
return new ShortcutInfo.Builder(context, getId())
|
return new ShortcutInfo.Builder(context, getId())
|
||||||
.setShortLabel(context.getString(R.string.my_top_tracks))
|
.setShortLabel(context.getString(R.string.my_top_tracks))
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public final class LatestShortcutType extends BaseShortcutType {
|
||||||
return PREFIX + ".latest";
|
return PREFIX + ".latest";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ShortcutInfo getShortcutInfo() {
|
public ShortcutInfo getShortcutInfo() {
|
||||||
return new ShortcutInfo.Builder(context, getId())
|
return new ShortcutInfo.Builder(context, getId())
|
||||||
.setShortLabel(context.getString(R.string.last_added))
|
.setShortLabel(context.getString(R.string.last_added))
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public final class ShuffleShortcutType extends BaseShortcutType {
|
||||||
return PREFIX + ".shuffle";
|
return PREFIX + ".shuffle";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ShortcutInfo getShortcutInfo() {
|
public ShortcutInfo getShortcutInfo() {
|
||||||
return new ShortcutInfo.Builder(context, getId())
|
return new ShortcutInfo.Builder(context, getId())
|
||||||
.setShortLabel(context.getString(R.string.action_shuffle))
|
.setShortLabel(context.getString(R.string.action_shuffle))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue