Skip to content

Commit

Permalink
Merge pull request #788 from florent37/fix-build-issues
Browse files Browse the repository at this point in the history
fix build and package renaming issue
  • Loading branch information
kalismeras61 authored Aug 11, 2023
2 parents 73196de + 929a8f9 commit abd84ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import android.support.v4.media.session.PlaybackStateCompat.ACTION_SEEK_TO
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.media.session.MediaButtonReceiver
import com.github.florent37.assets_audio_player.R
import com.google.android.exoplayer2.C
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
Expand All @@ -26,7 +25,9 @@ import kotlin.math.abs
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
import android.app.PendingIntent.FLAG_IMMUTABLE
import android.support.v4.media.session.MediaSessionCompat
import androidx.annotation.RequiresApi
import com.github.florent37.assets_audio_player.AssetsAudioPlayerPlugin
import com.github.florent37.assetsaudioplayer.R

class NotificationService : Service() {

Expand Down Expand Up @@ -114,6 +115,7 @@ class NotificationService : Service() {
}
}

@RequiresApi(Build.VERSION_CODES.ECLAIR)
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
if (intent.action == Intent.ACTION_MEDIA_BUTTON) {
MediaButtonsReceiver.getMediaSessionCompat(applicationContext).let {
Expand All @@ -138,6 +140,7 @@ class NotificationService : Service() {
.putExtra(TRACK_ID, audioMetas.trackID)
}

@RequiresApi(Build.VERSION_CODES.ECLAIR)
private fun displayNotification(action: NotificationAction.Show) {
GlobalScope.launch(Dispatchers.Main) {
val image = ImageDownloader.loadBitmap(context = applicationContext, imageMetas = action.audioMetas.image)
Expand Down Expand Up @@ -213,6 +216,7 @@ class NotificationService : Service() {
}
}

@RequiresApi(Build.VERSION_CODES.ECLAIR)
private fun displayNotification(action: NotificationAction.Show, bitmap: Bitmap?) {
createNotificationChannel()
val mediaSession = MediaButtonsReceiver.getMediaSessionCompat(applicationContext)
Expand Down Expand Up @@ -346,7 +350,7 @@ class NotificationService : Service() {

//fix for https://github.com/florent37/Flutter-AssetsAudioPlayer/issues/139
if (!action.isPlaying && Build.VERSION.SDK_INT >= 24) {
stopForeground(2)
stopForeground(STOP_FOREGROUND_DETACH)
}

}
Expand All @@ -369,12 +373,14 @@ class NotificationService : Service() {
}
}

@RequiresApi(Build.VERSION_CODES.ECLAIR)
private fun hideNotif() {
NotificationManagerCompat.from(applicationContext).cancel(NOTIFICATION_ID)
stopForeground(true)
stopSelf()
}

@RequiresApi(Build.VERSION_CODES.ECLAIR)
override fun onTaskRemoved(rootIntent: Intent) {
hideNotif()
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
10 changes: 8 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_neumorphic: ^3.2.0
flutter_neumorphic:
git:
url: https://github.com/den0206/Flutter-Neumorphic.git
ref: feature/remoce_accentcolor
rxdart: ^0.27.0
# for local file test
dio: ^5.2.1+1
path_provider: ^2.0.1
http: ^1.1.0
provider: ^6.0.0
file: ^6.1.0
file: ^7.0.0
#flutter_html: ^2.2.1

# flutter_audio_recorder: ^0.5.5
Expand All @@ -38,6 +41,9 @@ dev_dependencies:
build_web_compilers: ^4.0.4
pedantic: ^1.11.0

dependency_overrides:
file: ^7.0.0

# uncomment to use remote repos
# assets_audio_player: ^3.0.0
# assets_audio_player_web: ^3.0.0
Expand Down

0 comments on commit abd84ed

Please sign in to comment.