Small fixes

This commit is contained in:
Karim Abou Zeid 2015-03-24 21:56:21 +01:00
commit d3d37ccab3
12 changed files with 26 additions and 17 deletions

View file

@ -83,7 +83,8 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
holder.songTitle.setTextColor(accentColor);
holder.songInfo.setVisibility(View.GONE);
holder.overflowButton.setVisibility(View.GONE);
holder.albumArt.setPadding(48, 48, 48, 48);
final int padding = activity.getResources().getDimensionPixelSize(R.dimen.default_item_margin);
holder.albumArt.setPadding(padding, padding, padding, padding);
holder.albumArt.setColorFilter(accentColor);
holder.albumArt.setImageResource(R.drawable.ic_shuffle_white_48dp);
holder.separator.setVisibility(View.VISIBLE);

View file

@ -46,7 +46,7 @@ public class PlayingNotificationHelper {
R.layout.notification_playing_expanded);
notification = new NotificationCompat.Builder(service)
.setSmallIcon(R.drawable.notification_icon)
.setSmallIcon(R.drawable.ic_audiotrack_white_24dp)
.setContentIntent(getOpenMusicControllerPendingIntent())
.setCategory(NotificationCompat.CATEGORY_PROGRESS)
.setPriority(NotificationCompat.PRIORITY_MAX)

View file

@ -28,9 +28,11 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver {
break;
case KeyEvent.KEYCODE_HEADSETHOOK:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
case KeyEvent.KEYCODE_MEDIA_PLAY:
command = MusicService.ACTION_TOGGLE_PLAYBACK;
break;
case KeyEvent.KEYCODE_MEDIA_PLAY:
command = MusicService.ACTION_RESUME;
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
command = MusicService.ACTION_SKIP;
break;

View file

@ -41,6 +41,7 @@ import java.util.List;
public class MusicService extends Service implements MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener, AudioManager.OnAudioFocusChangeListener {
public static final String ACTION_TOGGLE_PLAYBACK = "com.kabouzeid.gramophone.action.TOGGLE_PLAYBACK";
public static final String ACTION_PLAY = "com.kabouzeid.gramophone.action.PLAY";
public static final String ACTION_RESUME = "com.kabouzeid.gramophone.action.RESUME";
public static final String ACTION_PAUSE = "com.kabouzeid.gramophone.action.PAUSE";
public static final String ACTION_STOP = "com.kabouzeid.gramophone.action.STOP";
public static final String ACTION_SKIP = "com.kabouzeid.gramophone.action.SKIP";
@ -56,7 +57,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
private final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
if (intent.getAction().compareTo(AudioManager.ACTION_AUDIO_BECOMING_NOISY) == 0) {
pausePlaying();
}
}
@ -145,6 +146,9 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
case ACTION_PLAY:
playSong();
break;
case ACTION_RESUME:
resumePlaying();
break;
case ACTION_REWIND:
back();
break;
@ -594,17 +598,19 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
}
public void resumePlaying() {
if (requestFocus()) {
if (isPlayerPrepared) {
player.start();
playingNotificationHelper.updatePlayState(isPlaying());
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.RESUME);
if(!isPlaying()) {
if (requestFocus()) {
if (isPlayerPrepared) {
player.start();
playingNotificationHelper.updatePlayState(isPlaying());
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.RESUME);
} else {
playSong();
}
} else {
playSong();
Toast.makeText(this, getResources().getString(R.string.audio_focus_denied), Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, getResources().getString(R.string.audio_focus_denied), Toast.LENGTH_SHORT).show();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -26,7 +26,7 @@
<string name="unknown_album">Unknown Album</string>
<string name="untitled_song">Untitled Song</string>
<string name="nothing_playing">Nothing is playing</string>
<string name="hint_fling_to_open">fling to open current playing</string>
<string name="hint_fling_to_open">Fling to toggle the now playing screen</string>
<string name="hint_fling_to_go_back">fling to return</string>
<string name="hint_press_again_to_exit">Press once again to exit!</string>
<string name="unplayable_file">Sorry - an error occurred while attempting to play this song</string>
@ -63,7 +63,7 @@
<string name="label_current_playing_queue">Playing queue</string>
<string name="close">Close</string>
<string name="save_as_playlist">Save as playlist</string>
<string name="credits">Gramophone is a completely free material designed music player by <b>Karim Abou Zeid</b>.\n\nIcon by <a href="http://cookicons.co/">Cookicons</a>\n\n<a href="https://plus.google.com/+KarimAbouZeid23697">Google+</a>&#160;&#160;&#160;<a href="https://twitter.com/karim23697">Twitter</a></string>
<string name="credits">Gramophone is a completely free material designed music player by <b>Karim Abou Zeid</b>.\n\n<a href="https://plus.google.com/+KarimAbouZeid23697">Google+</a>&#160;&#160;&#160;<a href="https://twitter.com/karim23697">Twitter</a>\n\nIcon by <a href="http://cookicons.co/">Cookicons</a></string>
<string name="title_activity_search">SearchActivity</string>
<string name="more">more</string>
<string name="no_results">No results</string>