New shadow + more infos songs and artists

This commit is contained in:
Karim Abou Zeid 2015-03-11 21:34:55 +01:00
commit b293123603
32 changed files with 272 additions and 179 deletions

View file

@ -1,7 +1,6 @@
package com.kabouzeid.gramophone;
import android.app.Application;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.preference.PreferenceManager;
@ -24,42 +23,26 @@ public class App extends Application {
public static Bus bus = new Bus(ThreadEnforcer.MAIN);
private MusicPlayerRemote playerRemote;
private int appTheme;
private SharedPreferences defaultSharedPreferences;
private RequestQueue requestQueue;
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
}
public MusicPlayerRemote getMusicPlayerRemote() {
if (playerRemote == null) {
playerRemote = new MusicPlayerRemote(this);
playerRemote.restorePreviousState();
}
return playerRemote;
MusicPlayerRemote.init(this);
}
public int getAppTheme() {
if (appTheme == 0) {
appTheme = getDefaultSharedPreferences().getInt(AppKeys.SP_THEME, R.style.Theme_MaterialMusic);
appTheme = PreferenceManager.getDefaultSharedPreferences(this).getInt(AppKeys.SP_THEME, R.style.Theme_MaterialMusic);
}
return appTheme;
}
public SharedPreferences getDefaultSharedPreferences() {
if (defaultSharedPreferences == null) {
defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
}
return defaultSharedPreferences;
}
public void setAppTheme(int appTheme) {
this.appTheme = appTheme;
defaultSharedPreferences.edit().putInt(AppKeys.SP_THEME, appTheme).apply();
PreferenceManager.getDefaultSharedPreferences(this).edit().putInt(AppKeys.SP_THEME, appTheme).apply();
}
public boolean isTablet() {

View file

@ -35,9 +35,12 @@ public class ArtistViewListAdapter extends ArrayAdapter<Artist> {
convertView = LayoutInflater.from(context).inflate(R.layout.item_artist_view, parent, false);
}
final TextView artistName = (TextView) convertView.findViewById(R.id.artist_name);
final TextView artistInfo = (TextView) convertView.findViewById(R.id.artist_info);
final ImageView artistArt = (ImageView) convertView.findViewById(R.id.artist_image);
artistName.setText(artist.name);
artistInfo.setText(artist.getSubTitle());
artistArt.setImageResource(R.drawable.default_artist_image);
LastFMArtistThumbnailUrlLoader.loadArtistThumbnailUrl(context, artist.name, false, new LastFMArtistThumbnailUrlLoader.ArtistThumbnailUrlLoaderCallback() {

View file

@ -14,6 +14,7 @@ import android.widget.TextView;
import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.adapter.songadapter.SongAdapter;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.helper.SongDetailDialogHelper;
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
import com.kabouzeid.gramophone.misc.AppKeys;
@ -49,7 +50,7 @@ public class PlayingQueueAdapter extends ArrayAdapter<Song> {
final ImageView overflowButton = (ImageView) convertView.findViewById(R.id.menu);
title.setText(song.title);
if (app.getMusicPlayerRemote().getPosition() == position) {
if (MusicPlayerRemote.getPosition() == position) {
playingIndicator.setVisibility(View.VISIBLE);
playingIndicator.setImageResource(R.drawable.ic_speaker_white_48dp);
} else {

View file

@ -12,6 +12,7 @@ import android.widget.TextView;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.model.SearchEntry;
import com.kabouzeid.gramophone.model.Song;
import com.kabouzeid.gramophone.ui.activities.SearchActivity;
import java.util.List;
@ -42,6 +43,11 @@ public class SearchAdapter extends ArrayAdapter<SearchEntry> {
subTitle.setVisibility(View.GONE);
imageView.setVisibility(View.GONE);
convertView.setBackgroundColor(getContext().getResources().getColor(R.color.materialmusic_default_bar_color));
} else if (item instanceof Song) {
title.setTypeface(null, Typeface.NORMAL);
subTitle.setVisibility(View.VISIBLE);
imageView.setVisibility(View.GONE);
convertView.setBackgroundColor(Color.TRANSPARENT);
} else {
title.setTypeface(null, Typeface.NORMAL);
subTitle.setVisibility(View.VISIBLE);

View file

@ -39,6 +39,7 @@ public class SongViewListAdapter extends SongAdapter {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_song_view, parent, false);
}
TextView songTitle = (TextView) convertView.findViewById(R.id.song_title);
TextView songInfo = (TextView) convertView.findViewById(R.id.song_info);
final ImageView albumArt = (ImageView) convertView.findViewById(R.id.album_art);
ImageView overflowButton = (ImageView) convertView.findViewById(R.id.menu);
@ -80,6 +81,8 @@ public class SongViewListAdapter extends SongAdapter {
});
songTitle.setText(song.title);
songInfo.setText(song.getSubTitle());
Picasso.with(getContext())
.load(MusicUtil.getAlbumArtUri(song.albumId))
.placeholder(R.drawable.default_album_art)

View file

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
import com.kabouzeid.gramophone.App;
@ -24,94 +25,93 @@ import java.util.List;
public class MusicPlayerRemote {
private static final String TAG = MusicPlayerRemote.class.getSimpleName();
private App app;
private static int position = -1;
private int position = -1;
private static List<Song> playingQueue;
private static List<Song> restoredOriginalQueue;
private List<Song> playingQueue;
private List<Song> restoredOriginalQueue;
private static Context context;
private static MusicService musicService;
private static Intent musicServiceIntent;
private MusicService musicService;
private Intent musicServiceIntent;
private boolean musicBound = false;
private ServiceConnection musicConnection = new ServiceConnection() {
private static ServiceConnection musicConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
MusicService.MusicBinder binder = (MusicService.MusicBinder) service;
musicService = binder.getService();
musicBound = true;
musicService.restorePreviousState(restoredOriginalQueue, playingQueue, position);
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.SERVICE_CONNECTED);
postToBus(MusicRemoteEvent.SERVICE_CONNECTED);
}
@Override
public void onServiceDisconnected(ComponentName name) {
musicBound = false;
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.SERVICE_DISCONNECTED);
musicService = null;
postToBus(MusicRemoteEvent.SERVICE_DISCONNECTED);
}
};
public MusicPlayerRemote(Context context) {
app = (App) context.getApplicationContext();
public static void init(final Context context) {
MusicPlayerRemote.context = context;
playingQueue = new ArrayList<>();
restoredOriginalQueue = new ArrayList<>();
startAndBindService();
restorePreviousState();
}
private void startAndBindService() {
private static void startAndBindService() {
if (musicServiceIntent == null) {
musicServiceIntent = new Intent(app, MusicService.class);
app.bindService(musicServiceIntent, musicConnection, Context.BIND_AUTO_CREATE);
app.startService(musicServiceIntent);
musicServiceIntent = new Intent(context, MusicService.class);
context.bindService(musicServiceIntent, musicConnection, Context.BIND_AUTO_CREATE);
context.startService(musicServiceIntent);
}
}
public boolean playSongAt(final int position) {
if (musicBound) {
public static boolean playSongAt(final int position) {
if (musicService != null) {
musicService.playSongAt(position);
}
return false;
}
public void pauseSong() {
if (musicBound) {
public static void pauseSong() {
if (musicService != null) {
musicService.pausePlaying();
}
}
public void playNextSong() {
if (musicBound) {
public static void playNextSong() {
if (musicService != null) {
musicService.playNextSong();
}
}
public void playPreviousSong() {
if (musicBound) {
public static void playPreviousSong() {
if (musicService != null) {
musicService.back();
}
}
public void back() {
if (musicBound) {
public static void back() {
if (musicService != null) {
musicService.back();
}
}
public boolean isPlaying() {
if (musicBound) {
public static boolean isPlaying() {
if (musicService != null) {
return musicService.isPlaying();
}
return false;
}
public void resumePlaying() {
if (musicBound) {
public static void resumePlaying() {
if (musicService != null) {
musicService.resumePlaying();
}
}
public long getCurrentSongId() {
if (musicBound) {
public static long getCurrentSongId() {
if (musicService != null) {
return musicService.getCurrentSongId();
}
try {
@ -121,14 +121,14 @@ public class MusicPlayerRemote {
}
}
public void openQueue(final List<Song> playingQueue, final int startPosition, final boolean startPlaying) {
this.playingQueue = playingQueue;
if (musicBound) {
musicService.openQueue(this.playingQueue, startPosition, startPlaying);
public static void openQueue(final List<Song> playingQueue, final int startPosition, final boolean startPlaying) {
MusicPlayerRemote.playingQueue = playingQueue;
if (musicService != null) {
musicService.openQueue(MusicPlayerRemote.playingQueue, startPosition, startPlaying);
}
}
public Song getCurrentSong() {
public static Song getCurrentSong() {
final int position = getPosition();
if (position != -1) {
return getPlayingQueue().get(position);
@ -136,89 +136,85 @@ public class MusicPlayerRemote {
return new Song();
}
public int getPosition() {
if (musicBound) {
public static int getPosition() {
if (musicService != null) {
position = musicService.getPosition();
}
return position;
}
private void setPosition(int position) {
this.position = position;
if (musicBound) {
private static void setPosition(int position) {
MusicPlayerRemote.position = position;
if (musicService != null) {
musicService.setPosition(position);
}
}
public List<Song> getPlayingQueue() {
if (musicBound) {
public static List<Song> getPlayingQueue() {
if (musicService != null) {
playingQueue = musicService.getPlayingQueue();
}
return playingQueue;
}
public int getSongProgressMillis() {
public static int getSongProgressMillis() {
if (isPlayerPrepared()) {
return musicService.getSongProgressMillis();
}
return -1;
}
public boolean isPlayerPrepared() {
if (musicBound) {
public static boolean isPlayerPrepared() {
if (musicService != null) {
return musicService.isPlayerPrepared();
}
return false;
}
public int getSongDurationMillis() {
public static int getSongDurationMillis() {
if (isPlayerPrepared()) {
return musicService.getSongDurationMillis();
}
return -1;
}
public boolean isMusicBound() {
return musicBound;
}
public void seekTo(int millis) {
if (musicBound) {
public static void seekTo(int millis) {
if (musicService != null) {
musicService.seekTo(millis);
}
}
public int getRepeatMode() {
if (musicBound) {
public static int getRepeatMode() {
if (musicService != null) {
return musicService.getRepeatMode();
}
return app.getDefaultSharedPreferences().getInt(AppKeys.SP_REPEAT_MODE, 0);
return PreferenceManager.getDefaultSharedPreferences(context).getInt(AppKeys.SP_REPEAT_MODE, 0);
}
public int getShuffleMode() {
if (musicBound) {
public static int getShuffleMode() {
if (musicService != null) {
return musicService.getShuffleMode();
}
return app.getDefaultSharedPreferences().getInt(AppKeys.SP_SHUFFLE_MODE, 0);
return PreferenceManager.getDefaultSharedPreferences(context).getInt(AppKeys.SP_SHUFFLE_MODE, 0);
}
public boolean cycleRepeatMode() {
if (musicBound) {
public static boolean cycleRepeatMode() {
if (musicService != null) {
musicService.cycleRepeatMode();
return true;
}
return false;
}
public boolean toggleShuffleMode() {
if (musicBound) {
public static boolean toggleShuffleMode() {
if (musicService != null) {
musicService.toggleShuffle();
return true;
}
return false;
}
public void moveSong(int from, int to) {
public static void moveSong(int from, int to) {
final int currentPosition = getPosition();
Song songToMove = getPlayingQueue().remove(from);
getPlayingQueue().add(to, songToMove);
@ -231,27 +227,27 @@ public class MusicPlayerRemote {
}
}
private void notifyOnMusicRemoteEventListeners(int event) {
private static void postToBus(int event) {
MusicRemoteEvent musicRemoteEvent = new MusicRemoteEvent(event);
App.bus.post(musicRemoteEvent);
}
@SuppressWarnings("unchecked")
public void restorePreviousState() {
public static void restorePreviousState() {
try {
List restoredQueue = (ArrayList<Song>) InternalStorageUtil.readObject(app, AppKeys.IS_PLAYING_QUEUE);
List restoredOriginalQueue = (ArrayList<Song>) InternalStorageUtil.readObject(app, AppKeys.IS_ORIGINAL_PLAYING_QUEUE);
int restoredPosition = (int) InternalStorageUtil.readObject(app, AppKeys.IS_POSITION_IN_QUEUE);
List restoredQueue = (ArrayList<Song>) InternalStorageUtil.readObject(context, AppKeys.IS_PLAYING_QUEUE);
List restoredOriginalQueue = (ArrayList<Song>) InternalStorageUtil.readObject(context, AppKeys.IS_ORIGINAL_PLAYING_QUEUE);
int restoredPosition = (int) InternalStorageUtil.readObject(context, AppKeys.IS_POSITION_IN_QUEUE);
if (musicBound) {
if (musicService != null) {
musicService.restorePreviousState(restoredOriginalQueue, restoredQueue, restoredPosition);
}
playingQueue = restoredQueue;
this.restoredOriginalQueue = restoredOriginalQueue;
MusicPlayerRemote.restoredOriginalQueue = restoredOriginalQueue;
position = restoredPosition;
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.STATE_RESTORED);
postToBus(MusicRemoteEvent.STATE_RESTORED);
} catch (IOException | ClassNotFoundException | ClassCastException e) {
Log.e(TAG, "error while restoring music service state", e);
playingQueue = new ArrayList<>();

View file

@ -20,7 +20,7 @@ import java.util.List;
public class PlayingQueueDialogHelper {
public static MaterialDialog getDialog(Context context, SongAdapter.GoToAble goToAble) {
final App app = (App) context.getApplicationContext();
List<Song> playingQueue = app.getMusicPlayerRemote().getPlayingQueue();
List<Song> playingQueue = MusicPlayerRemote.getPlayingQueue();
if (playingQueue.isEmpty()) {
return null;
}
@ -49,14 +49,14 @@ public class PlayingQueueDialogHelper {
dragSortListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
app.getMusicPlayerRemote().playSongAt(position);
MusicPlayerRemote.playSongAt(position);
playingQueueAdapter.notifyDataSetChanged();
}
});
dragSortListView.setDropListener(new DragSortListView.DropListener() {
@Override
public void drop(int from, int to) {
app.getMusicPlayerRemote().moveSong(from, to);
MusicPlayerRemote.moveSong(from, to);
playingQueueAdapter.notifyDataSetChanged();
}
});

View file

@ -3,10 +3,6 @@ package com.kabouzeid.gramophone.model;
import android.content.Context;
import android.widget.ImageView;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.util.MusicUtil;
import com.squareup.picasso.Picasso;
import java.io.Serializable;
/**
@ -57,9 +53,6 @@ public class Song implements Serializable, SearchEntry {
@Override
public void loadImage(Context context, ImageView imageView) {
imageView.setImageResource(R.drawable.default_album_art);
Picasso.with(context)
.load(MusicUtil.getAlbumArtUri(albumId))
.into(imageView);
}
}

View file

@ -24,6 +24,7 @@ import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.adapter.songadapter.SongAdapter;
import com.kabouzeid.gramophone.comparator.SongTrackNumberComparator;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
import com.kabouzeid.gramophone.loader.AlbumLoader;
import com.kabouzeid.gramophone.loader.AlbumSongLoader;
@ -321,7 +322,7 @@ public class AlbumDetailActivity extends AbsFabActivity implements KabViewsDisab
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position > 0) {
app.getMusicPlayerRemote().openQueue(songs, position - 1, true);
MusicPlayerRemote.openQueue(songs, position - 1, true);
}
}
});

View file

@ -6,6 +6,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
@ -25,6 +26,7 @@ import com.afollestad.materialdialogs.MaterialDialog;
import com.google.samples.apps.iosched.ui.widget.SlidingTabLayout;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.helper.AboutDeveloperDialogHelper;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.helper.PlayingQueueDialogHelper;
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
import com.kabouzeid.gramophone.misc.AppKeys;
@ -73,7 +75,7 @@ public class MainActivity extends AbsFabActivity
private void setUpViewPager() {
viewPagerAdapter = new MainActivityViewPagerAdapter(this);
viewPager.setAdapter(viewPagerAdapter);
int startPosition = getApp().getDefaultSharedPreferences().getInt(AppKeys.SP_VIEWPAGER_ITEM_POSITION, 1);
int startPosition = PreferenceManager.getDefaultSharedPreferences(this).getInt(AppKeys.SP_VIEWPAGER_ITEM_POSITION, 1);
viewPager.setCurrentItem(startPosition);
navigationDrawerFragment.setItemChecked(startPosition);
@ -87,7 +89,7 @@ public class MainActivity extends AbsFabActivity
@Override
public void onPageSelected(final int position) {
getApp().getDefaultSharedPreferences().edit().putInt(AppKeys.SP_VIEWPAGER_ITEM_POSITION, position).apply();
PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit().putInt(AppKeys.SP_VIEWPAGER_ITEM_POSITION, position).apply();
navigationDrawerFragment.setItemChecked(position);
}
@ -147,7 +149,7 @@ public class MainActivity extends AbsFabActivity
private void updateNavigationDrawerHeader() {
if (navigationDrawerFragment != null) {
Song song = getApp().getMusicPlayerRemote().getCurrentSong();
Song song = MusicPlayerRemote.getCurrentSong();
if (song.id != -1) {
Picasso.with(this)
.load(MusicUtil.getAlbumArtUri(song.albumId))

View file

@ -21,6 +21,7 @@ import android.widget.Toast;
import com.afollestad.materialdialogs.MaterialDialog;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.helper.PlayingQueueDialogHelper;
import com.kabouzeid.gramophone.helper.SongDetailDialogHelper;
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistImageUrlLoader;
@ -117,7 +118,7 @@ public class MusicControllerActivity extends AbsFabActivity {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
getApp().getMusicPlayerRemote().seekTo(progress);
MusicPlayerRemote.seekTo(progress);
}
}
@ -135,13 +136,13 @@ public class MusicControllerActivity extends AbsFabActivity {
nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getApp().getMusicPlayerRemote().playNextSong();
MusicPlayerRemote.playNextSong();
}
});
prevButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getApp().getMusicPlayerRemote().back();
MusicPlayerRemote.back();
}
});
}
@ -151,13 +152,13 @@ public class MusicControllerActivity extends AbsFabActivity {
shuffleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getApp().getMusicPlayerRemote().toggleShuffleMode();
MusicPlayerRemote.toggleShuffleMode();
}
});
}
private void updateShuffleState() {
switch (getApp().getMusicPlayerRemote().getShuffleMode()) {
switch (MusicPlayerRemote.getShuffleMode()) {
case MusicService.SHUFFLE_MODE_SHUFFLE:
shuffleButton.setImageResource(R.drawable.ic_shuffle_white_48dp);
break;
@ -172,13 +173,13 @@ public class MusicControllerActivity extends AbsFabActivity {
repeatButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getApp().getMusicPlayerRemote().cycleRepeatMode();
MusicPlayerRemote.cycleRepeatMode();
}
});
}
private void updateRepeatState() {
switch (getApp().getMusicPlayerRemote().getRepeatMode()) {
switch (MusicPlayerRemote.getRepeatMode()) {
case MusicService.REPEAT_MODE_NONE:
repeatButton.setImageResource(R.drawable.ic_repeat_grey600_48dp);
break;
@ -299,7 +300,7 @@ public class MusicControllerActivity extends AbsFabActivity {
}
private void getCurrentSong() {
song = getApp().getMusicPlayerRemote().getCurrentSong();
song = MusicPlayerRemote.getCurrentSong();
if (song.id == -1) {
finish();
}
@ -312,10 +313,10 @@ public class MusicControllerActivity extends AbsFabActivity {
public void run() {
int currentPosition = 0;
int total = 0;
while (getApp().getMusicPlayerRemote().isMusicBound() && !killThreads) {
while (!killThreads) {
try {
total = getApp().getMusicPlayerRemote().getSongDurationMillis();
currentPosition = getApp().getMusicPlayerRemote().getSongProgressMillis();
total = MusicPlayerRemote.getSongDurationMillis();
currentPosition = MusicPlayerRemote.getSongProgressMillis();
Thread.sleep(1);
} catch (InterruptedException e) {
return;

View file

@ -19,6 +19,7 @@ import android.widget.ListView;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.adapter.SearchAdapter;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.loader.AlbumLoader;
import com.kabouzeid.gramophone.loader.ArtistLoader;
import com.kabouzeid.gramophone.loader.SongLoader;
@ -60,7 +61,7 @@ public class SearchActivity extends AbsBaseActivity {
if (item instanceof Song) {
List<Song> playList = new ArrayList<>();
playList.add((Song) item);
getApp().getMusicPlayerRemote().openQueue(playList, 0, true);
MusicPlayerRemote.openQueue(playList, 0, true);
} else if (item instanceof Album) {
goToAlbum(((Album) item).id, new Pair[]{Pair.create(view.findViewById(R.id.image), getResources().getString(R.string.transition_album_cover))});
} else if (item instanceof Artist) {

View file

@ -13,6 +13,7 @@ import com.crashlytics.android.Crashlytics;
import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.adapter.songadapter.SongAdapter;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
import com.kabouzeid.gramophone.misc.AppKeys;
import com.kabouzeid.gramophone.ui.activities.AlbumDetailActivity;
@ -74,7 +75,7 @@ public abstract class AbsBaseActivity extends ActionBarActivity implements KabVi
}
protected boolean openCurrentPlayingIfPossible(Pair[] sharedViews) {
if (getApp().getMusicPlayerRemote().getPosition() != -1) {
if (MusicPlayerRemote.getPosition() != -1) {
if (areViewsEnabled()) {
disableViews();
Intent intent = new Intent(this, MusicControllerActivity.class);

View file

@ -10,6 +10,7 @@ import android.widget.Toast;
import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.misc.SmallOnGestureListener;
import com.kabouzeid.gramophone.model.MusicRemoteEvent;
import com.melnykov.fab.FloatingActionButton;
@ -47,11 +48,11 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
getFab().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getApp().getMusicPlayerRemote().getPosition() != -1) {
if (getApp().getMusicPlayerRemote().isPlaying()) {
getApp().getMusicPlayerRemote().pauseSong();
if (MusicPlayerRemote.getPosition() != -1) {
if (MusicPlayerRemote.isPlaying()) {
MusicPlayerRemote.pauseSong();
} else {
getApp().getMusicPlayerRemote().resumePlaying();
MusicPlayerRemote.resumePlaying();
}
} else {
Toast.makeText(AbsFabActivity.this, getResources().getString(R.string.nothing_playing), Toast.LENGTH_SHORT).show();
@ -77,7 +78,7 @@ public abstract class AbsFabActivity extends AbsBaseActivity {
}
private void updateFabState() {
if (getApp().getMusicPlayerRemote().isPlaying()) {
if (MusicPlayerRemote.isPlaying()) {
getFab().setImageResource(R.drawable.ic_pause_white_24dp);
} else {
getFab().setImageResource(R.drawable.ic_play_arrow_white_24dp);

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.LayoutInflater;
@ -62,7 +63,7 @@ public class NavigationDrawerFragment extends Fragment {
if (!userLearnedDrawer && !fromSavedInstanceState) {
this.drawerLayout.openDrawer(fragmentContainerView);
userLearnedDrawer = true;
app.getDefaultSharedPreferences().edit().putBoolean(AppKeys.SP_USER_LEARNED_DRAWER, true).apply();
PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putBoolean(AppKeys.SP_USER_LEARNED_DRAWER, true).apply();
}
}
@ -91,7 +92,7 @@ public class NavigationDrawerFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
app = (App) getActivity().getApplicationContext();
userLearnedDrawer = app.getDefaultSharedPreferences().getBoolean(AppKeys.SP_USER_LEARNED_DRAWER, false);
userLearnedDrawer = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean(AppKeys.SP_USER_LEARNED_DRAWER, false);
if (savedInstanceState != null) {
setItemChecked(savedInstanceState.getInt(STATE_SELECTED_POSITION));
fromSavedInstanceState = true;

View file

@ -6,6 +6,7 @@ import android.widget.ListAdapter;
import com.kabouzeid.gramophone.adapter.songadapter.SongAdapter;
import com.kabouzeid.gramophone.comparator.SongAlphabeticComparator;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.loader.ArtistSongLoader;
import com.kabouzeid.gramophone.model.Song;
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
@ -29,7 +30,7 @@ public class ViewPagerTabArtistSongListFragment extends AbsViewPagerTabArtistLis
setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
app.getMusicPlayerRemote().openQueue(songs, position, true);
MusicPlayerRemote.openQueue(songs, position, true);
}
});
return adapter;

View file

@ -12,6 +12,7 @@ import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.adapter.songadapter.SongViewListAdapter;
import com.kabouzeid.gramophone.comparator.SongAlphabeticComparator;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.loader.SongLoader;
import com.kabouzeid.gramophone.model.Song;
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
@ -73,7 +74,7 @@ public class SongViewFragment extends MainActivityFragment {
absListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
app.getMusicPlayerRemote().openQueue(songs, position, true);
MusicPlayerRemote.openQueue(songs, position, true);
}
});

View file

@ -10,6 +10,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.util.TypedValue;
import android.view.View;
@ -116,7 +117,7 @@ public class Util {
}
boolean state = false;
final boolean onlyOnWifi = ((App) context.getApplicationContext()).getDefaultSharedPreferences().getBoolean(AppKeys.SP_ONLY_ON_WIFI, true);
final boolean onlyOnWifi = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(AppKeys.SP_ONLY_ON_WIFI, true);
/* Monitor network connections */
final ConnectivityManager connectivityManager = (ConnectivityManager) context

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<stroke android:width="5px" android:color="#222222" />
<padding android:left="5px" android:top="5px" android:right="5px"
android:bottom="5px" />
</shape>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="3px">
<shape android:shape="line">
<stroke
android:color="#161616"
android:width="3px"
/>
<size
android:height="6px"
/>
</shape>
</item>
<item android:top="3px">
<shape android:shape="line">
<stroke
android:color="#444444"
android:width="3px"
/>
<size
android:height="6px"
/>
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:endColor="@android:color/transparent"
android:startColor="#34000000"/>
</shape>

View file

@ -57,7 +57,6 @@
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textColor="?attr/title_text_color"/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -50,6 +50,11 @@
android:layout_height="@dimen/tab_height"
android:background="?colorPrimary"
android:elevation="2dp"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/shadow_down" />
</LinearLayout>
<LinearLayout

View file

@ -15,13 +15,12 @@
android:src="@drawable/default_album_art"
android:transitionName="@string/transition_album_cover"/>
<LinearLayout
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/footer"
android:layout_alignTop="@+id/progress_container"
android:background="@drawable/navigation_drawer_gradient"
android:orientation="vertical"/>
android:background="@drawable/shadow_up"/>
<LinearLayout
android:id="@+id/progress_container"
@ -90,6 +89,12 @@
</LinearLayout>
<View
android:layout_below="@id/footer"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/shadow_down" />
<RelativeLayout
android:id="@+id/media_controller_container"
android:layout_width="match_parent"

View file

@ -1,9 +1,10 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
@ -12,10 +13,20 @@
android:elevation="@dimen/toolbar_elevation"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<ListView
android:dividerHeight="0dp"
android:divider="@null"
android:id="@+id/list"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/shadow_down" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="0px"
android:divider="@null"/>
</FrameLayout>
</LinearLayout>

View file

@ -2,18 +2,16 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="2dp">
android:layout_height="match_parent">
<ListView
android:listSelector="?rect_selector"
android:id="@+id/absList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:dividerHeight="0px"
android:divider="@null"
android:dividerHeight="0dp"
android:listSelector="?rect_selector"
android:numColumns="@integer/grid_columns"
android:padding="2dp"
android:scrollbars="vertical"/>
</LinearLayout>

View file

@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_alignParentBottom="true"
android:background="@drawable/navigation_drawer_gradient"
android:background="@drawable/shadow_up"
android:orientation="vertical"/>
<LinearLayout

View file

@ -3,8 +3,7 @@
android:id="@+id/fragment_songview"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="2dp">
android:layout_height="match_parent">
<ListView
android:listSelector="?rect_selector"
@ -12,9 +11,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:dividerHeight="0px"
android:divider="@null"
android:dividerHeight="0dp"
android:numColumns="@integer/grid_columns"
android:padding="2dp"
android:scrollbars="vertical"/>
</LinearLayout>

View file

@ -12,20 +12,37 @@
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:background="@drawable/image_background"
android:gravity="center"
android:scaleType="centerCrop"
/>
<TextView
android:id="@+id/artist_name"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:fontFamily="sans-serif"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
android:orientation="vertical">
<TextView
android:id="@+id/artist_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:fontFamily="sans-serif"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
<TextView
android:id="@+id/artist_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:fontFamily="sans-serif"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
</LinearLayout>
</LinearLayout>

View file

@ -12,15 +12,18 @@
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:background="@drawable/image_background"
android:gravity="center"
android:scaleType="centerCrop"
/>
<LinearLayout
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
@ -29,7 +32,7 @@
android:layout_marginRight="16dp"
android:fontFamily="sans-serif"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
<TextView
android:id="@+id/sub_title"
@ -39,6 +42,6 @@
android:layout_marginRight="16dp"
android:fontFamily="sans-serif"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Small"/>
</LinearLayout>
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
</LinearLayout>
</LinearLayout>

View file

@ -43,6 +43,8 @@
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
<ImageView
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:id="@+id/menu"
style="@style/OverFlowButton"
android:layout_gravity="center_vertical"/>

View file

@ -12,23 +12,42 @@
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:background="@drawable/image_background"
android:gravity="center"
android:scaleType="centerCrop"
/>
<TextView
android:id="@+id/song_title"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:fontFamily="sans-serif"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
android:orientation="vertical">
<TextView
android:id="@+id/song_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:fontFamily="sans-serif"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
<TextView
android:id="@+id/song_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:fontFamily="sans-serif"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
</LinearLayout>
<ImageView
android:id="@+id/menu"
style="@style/OverFlowButton"
android:layout_gravity="center_vertical"/>
android:layout_gravity="center_vertical"
android:layout_marginRight="2dp"/>
</LinearLayout>