Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearfog committed Apr 23, 2024
1 parent fbd305c commit 413c92f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import androidx.core.app.NotificationManagerCompat;

import org.nuclearfog.apollo.cache.ImageCache;
import org.nuclearfog.apollo.player.AudioEffects;

import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -27,6 +26,7 @@
* released within {@link ImageCache}.
*
* @author Andrew Neal ([email protected])
* @author nuclearfog
*/
public class ApolloApplication extends Application {

Expand Down Expand Up @@ -59,8 +59,6 @@ public void onTerminate() {
// remove notification
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.cancelAll();
// release audioeffects
AudioEffects.release();
} catch (SecurityException exception) {
// ignore
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* expanded notification by default.
*
* @author Andrew Neal ([email protected])
* @author nuclearfog
*/
public class NotificationHelper {

Expand Down Expand Up @@ -160,9 +161,9 @@ public void updateNotification() {
}

/**
* cancel notification when app is in foreground
* dismiss notification when app is in foreground
*/
public void cancelNotification() {
public void dismissNotification() {
postNotification(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.nuclearfog.apollo.cache.ImageFetcher;
import org.nuclearfog.apollo.model.Album;
import org.nuclearfog.apollo.model.Song;
import org.nuclearfog.apollo.player.AudioEffects;
import org.nuclearfog.apollo.player.MultiPlayer;
import org.nuclearfog.apollo.player.MusicPlayerHandler;
import org.nuclearfog.apollo.provider.FavoritesStore;
Expand All @@ -74,6 +75,8 @@
/**
* A background {@link Service} used to keep music playing between activities
* and when the user moves Apollo into the background.
*
* @author nuclearfog
*/
public class MusicPlaybackService extends MediaBrowserServiceCompat implements OnAudioFocusChangeListener {
/**
Expand Down Expand Up @@ -550,6 +553,7 @@ public void onDestroy() {
audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, APOLLO_PACKAGE_NAME);
sendBroadcast(audioEffectsIntent);
AudioEffects.release();
// remove any pending alarms
mAlarmManager.cancel(mShutdownIntent);
// Release the player
Expand All @@ -562,7 +566,7 @@ public void onDestroy() {
unregisterReceiver(mUnmountReceiver);
unregisterReceiver(mIntentReceiver);
// remove notification
mNotificationHelper.cancelNotification();
mNotificationHelper.dismissNotification();
super.onDestroy();
}

Expand Down Expand Up @@ -593,12 +597,14 @@ public void onAudioFocusChange(int focusChange) {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
mServiceStartId = startId;
// set empty notification to keep service alive
mNotificationHelper.createNotification(false);
if (intent != null) {
if (intent.hasExtra(EXTRA_FOREGROUND)) {
isForeground = intent.getBooleanExtra(EXTRA_FOREGROUND, false);
if (isForeground) {
stopForeground(true);
mNotificationHelper.cancelNotification();
mNotificationHelper.dismissNotification();
} else if (isPlaying()) {
mNotificationHelper.createNotification(true);
}
Expand Down Expand Up @@ -654,7 +660,7 @@ else if (CMDSTOP.equals(command) || ACTION_STOP.equals(action)) {
mPausedByTransientLossOfFocus = false;
seek(0);
releaseServiceUiAndStop();
mNotificationHelper.cancelNotification();
mNotificationHelper.dismissNotification();
}
// repeat set
else if (ACTION_REPEAT.equals(action)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ public static void notifyForegroundStateChanged(Context context, boolean inForeg
Intent intent = new Intent(context, MusicPlaybackService.class);
intent.setAction(MusicPlaybackService.CHANGED_FOREGROUND_STATE);
intent.putExtra(MusicPlaybackService.EXTRA_FOREGROUND, sForegroundActivities != 0);
context.startService(intent); //todo
context.startService(intent);
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@
<string name="settings_download_missing_artwork_title">Fehlende Albencover laden</string>
<string name="settings_download_artist_images_title">Fehlende Interpretenbilder laden</string>
<string name="settings_open_source_licenses">Open-Source-Lizenzen</string>
<string name="settings_disable_bat_opt_title">Batterie-Optimierungen deaktivieren</string>
<string name="settings_disable_bat_opt_summary">Batterie-Optimierungen deaktivieren falls es Unterbrechungen beim Abspielen kommt</string>
<string name="settings_disable_bat_opt_title">Akku-Optimierungen deaktivieren</string>
<string name="settings_disable_bat_opt_summary">Akku-Optimierungen deaktivieren falls es zu Unterbrechungen beim Abspielen kommt</string>
<string name="settings_use_old_notification">Altes Benachrichtigungs-Layout verwenden</string>
<string name="settings_use_old_notification_summary">Aktivieren, falls es zu Darstellungsproblemen kommt</string>
<string name="settings_version_title">Version</string>
Expand Down

0 comments on commit 413c92f

Please sign in to comment.