diff --git a/Smodr/src/main/AndroidManifest.xml b/Smodr/src/main/AndroidManifest.xml index daf786a7..415d8ed8 100755 --- a/Smodr/src/main/AndroidManifest.xml +++ b/Smodr/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="15" + android:versionName="1.4.6"> diff --git a/Smodr/src/main/java/com/kevintcoughlin/smodr/services/MediaPlaybackService.java b/Smodr/src/main/java/com/kevintcoughlin/smodr/services/MediaPlaybackService.java index 0f56f16a..11e2e018 100644 --- a/Smodr/src/main/java/com/kevintcoughlin/smodr/services/MediaPlaybackService.java +++ b/Smodr/src/main/java/com/kevintcoughlin/smodr/services/MediaPlaybackService.java @@ -9,8 +9,10 @@ import android.graphics.BitmapFactory; import android.media.MediaPlayer; import android.os.IBinder; +import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.StringRes; import android.support.v4.app.NotificationCompat; import android.support.v4.app.TaskStackBuilder; import com.kevintcoughlin.smodr.R; @@ -129,18 +131,17 @@ private void stopPlayback() { private void createNotification() { final Intent mIntent = new Intent(this, MediaPlaybackService.class); + mIntent.setAction(getAction()); final PendingIntent mPendingIntent = PendingIntent.getService(this, 0, mIntent, PendingIntent.FLAG_UPDATE_CURRENT); - mIntent.setAction(ACTION_STOP); - final NotificationCompat.Action action = new NotificationCompat.Action.Builder( - R.drawable.ic_action_pause, - getString(R.string.notification_action_pause), + getIcon(), + getTitle(), mPendingIntent).build(); final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.icon)) - .setSmallIcon(R.drawable.ic_action_play) + .setSmallIcon(getIcon()) .setOngoing(true) .setContentTitle(mTitle) .setContentText(mDescription) @@ -171,4 +172,22 @@ public void onPrepared(MediaPlayer mediaPlayer) { createNotification(); mPrepared = true; } + + @DrawableRes + private int getIcon() { + return (mMediaPlayer != null && mMediaPlayer.isPlaying()) + ? R.drawable.ic_action_pause + : R.drawable.ic_action_play; + } + + @StringRes + private String getTitle() { + return (mMediaPlayer != null && mMediaPlayer.isPlaying()) + ? getString(R.string.notification_action_pause) + : getString(R.string.notification_action_play); + } + + private String getAction() { + return (mMediaPlayer != null && mMediaPlayer.isPlaying()) ? ACTION_PAUSE : ACTION_RESUME; + } } \ No newline at end of file diff --git a/Smodr/src/main/res/values/strings.xml b/Smodr/src/main/res/values/strings.xml index bf95328f..ce9a5fbb 100755 --- a/Smodr/src/main/res/values/strings.xml +++ b/Smodr/src/main/res/values/strings.xml @@ -5,4 +5,5 @@ Cover art 889919744389128 C6D397172C2598AF256CF30C6393FBFC + Play