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

@ -23,8 +23,8 @@ android {
applicationId "com.kabouzeid.gramophone" applicationId "com.kabouzeid.gramophone"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 22 targetSdkVersion 22
versionCode 4 versionCode 5
versionName "0.9.2b" versionName "0.9.3b"
} }
compileOptions { compileOptions {

View file

@ -83,7 +83,8 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
holder.songTitle.setTextColor(accentColor); holder.songTitle.setTextColor(accentColor);
holder.songInfo.setVisibility(View.GONE); holder.songInfo.setVisibility(View.GONE);
holder.overflowButton.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.setColorFilter(accentColor);
holder.albumArt.setImageResource(R.drawable.ic_shuffle_white_48dp); holder.albumArt.setImageResource(R.drawable.ic_shuffle_white_48dp);
holder.separator.setVisibility(View.VISIBLE); holder.separator.setVisibility(View.VISIBLE);

View file

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

View file

@ -28,9 +28,11 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver {
break; break;
case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_HEADSETHOOK:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
case KeyEvent.KEYCODE_MEDIA_PLAY:
command = MusicService.ACTION_TOGGLE_PLAYBACK; command = MusicService.ACTION_TOGGLE_PLAYBACK;
break; break;
case KeyEvent.KEYCODE_MEDIA_PLAY:
command = MusicService.ACTION_RESUME;
break;
case KeyEvent.KEYCODE_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_NEXT:
command = MusicService.ACTION_SKIP; command = MusicService.ACTION_SKIP;
break; 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 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_TOGGLE_PLAYBACK = "com.kabouzeid.gramophone.action.TOGGLE_PLAYBACK";
public static final String ACTION_PLAY = "com.kabouzeid.gramophone.action.PLAY"; 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_PAUSE = "com.kabouzeid.gramophone.action.PAUSE";
public static final String ACTION_STOP = "com.kabouzeid.gramophone.action.STOP"; public static final String ACTION_STOP = "com.kabouzeid.gramophone.action.STOP";
public static final String ACTION_SKIP = "com.kabouzeid.gramophone.action.SKIP"; 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() { private final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { 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(); pausePlaying();
} }
} }
@ -145,6 +146,9 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
case ACTION_PLAY: case ACTION_PLAY:
playSong(); playSong();
break; break;
case ACTION_RESUME:
resumePlaying();
break;
case ACTION_REWIND: case ACTION_REWIND:
back(); back();
break; break;
@ -594,6 +598,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
} }
public void resumePlaying() { public void resumePlaying() {
if(!isPlaying()) {
if (requestFocus()) { if (requestFocus()) {
if (isPlayerPrepared) { if (isPlayerPrepared) {
player.start(); player.start();
@ -607,6 +612,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
Toast.makeText(this, getResources().getString(R.string.audio_focus_denied), Toast.LENGTH_SHORT).show(); Toast.makeText(this, getResources().getString(R.string.audio_focus_denied), Toast.LENGTH_SHORT).show();
} }
} }
}
public void playPreviousSong() { public void playPreviousSong() {
if (position != -1) { if (position != -1) {

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="unknown_album">Unknown Album</string>
<string name="untitled_song">Untitled Song</string> <string name="untitled_song">Untitled Song</string>
<string name="nothing_playing">Nothing is playing</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_fling_to_go_back">fling to return</string>
<string name="hint_press_again_to_exit">Press once again to exit!</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> <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="label_current_playing_queue">Playing queue</string>
<string name="close">Close</string> <string name="close">Close</string>
<string name="save_as_playlist">Save as playlist</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="title_activity_search">SearchActivity</string>
<string name="more">more</string> <string name="more">more</string>
<string name="no_results">No results</string> <string name="no_results">No results</string>