Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in Urgent.fm #869

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class MediaNotificationBuilder {

Notification buildNotification(MediaSessionCompat mediaSession) {
MediaControllerCompat controller = mediaSession.getController();
var playbackState = controller.getPlaybackState();
if (playbackState == null) {
return null; // Nothing we can do currently.
}

// Construct the actual notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, ChannelCreator.URGENT_CHANNEL);
Expand All @@ -65,10 +69,10 @@ Notification buildNotification(MediaSessionCompat mediaSession) {
.setShowActionsInCompactView(0);

// Construct the play/pause button.
boolean isPlaying = controller.getPlaybackState().getState() == PlaybackStateCompat.STATE_PLAYING;
boolean isConnecting = controller.getPlaybackState().getState() == PlaybackStateCompat.STATE_CONNECTING
|| controller.getPlaybackState().getState() == PlaybackStateCompat.STATE_BUFFERING;
boolean isError = controller.getPlaybackState().getState() == PlaybackStateCompat.STATE_ERROR;
boolean isPlaying = playbackState.getState() == PlaybackStateCompat.STATE_PLAYING;
boolean isConnecting = playbackState.getState() == PlaybackStateCompat.STATE_CONNECTING
|| playbackState.getState() == PlaybackStateCompat.STATE_BUFFERING;
boolean isError = playbackState.getState() == PlaybackStateCompat.STATE_ERROR;
if (isPlaying || isConnecting) {
builder.addAction(new NotificationCompat.Action(
R.drawable.noti_ic_stop,
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
toolsVersion = null;
platformToolsVersion = androidVersions.platformToolsVersion;
buildToolsVersions = [ androidVersions.buildToolsVersions ];
includeEmulator = false;
includeEmulator = true;
emulatorVersion = "34.1.9";
includeSystemImages = true;
systemImageTypes = [ "google_apis_playstore" ];
abiVersions = [ "x86_64" ];
platformVersions = [ androidVersions.platformVersions ];
# Enable once nixpkgs is fixed...
includeSources = false;
includeSources = true;
includeNDK = false;
useGoogleAPIs = true;
includeExtras = [
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# SOFTWARE.
#

android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.useAndroidX=true
Expand Down