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