diff --git a/src/musikdroid/app/build.gradle b/src/musikdroid/app/build.gradle index 0eb850d58..130742651 100644 --- a/src/musikdroid/app/build.gradle +++ b/src/musikdroid/app/build.gradle @@ -32,9 +32,15 @@ android { buildTypes { release { - minifyEnabled false + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } + + debug { + minifyEnabled false + ext.enableCrashlytics = false + ext.alwaysUpdateBuildId = false + } } } @@ -47,36 +53,36 @@ repositories { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + implementation fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile(name:'android-taskrunner-0.5', ext:'aar') + implementation(name:'android-taskrunner-0.5', ext:'aar') - compile(name:'videocache-2.8.0-pre', ext:'aar') - compile 'org.slf4j:slf4j-android:1.7.21' + implementation(name:'videocache-2.8.0-pre', ext:'aar') + implementation 'org.slf4j:slf4j-android:1.7.21' - compile "android.arch.persistence.room:runtime:1.0.0-alpha3" + implementation "android.arch.persistence.room:runtime:1.0.0-alpha3" annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha3" kapt "android.arch.persistence.room:compiler:1.0.0-alpha3" - compile 'com.neovisionaries:nv-websocket-client:1.31' - compile 'com.squareup.okhttp3:okhttp:3.8.0' - compile 'com.github.bumptech.glide:glide:3.8.0' - compile 'io.reactivex.rxjava2:rxjava:2.1.0' - compile 'io.reactivex.rxjava2:rxandroid:2.0.1' - compile 'com.google.android.exoplayer:exoplayer:r2.4.2' - compile 'com.google.android.exoplayer:extension-okhttp:r2.4.2' - compile 'com.github.pluscubed:recycler-fast-scroll:0.3.2@aar' - compile 'com.facebook.stetho:stetho:1.5.0' + implementation 'com.neovisionaries:nv-websocket-client:1.31' + implementation 'com.squareup.okhttp3:okhttp:3.8.0' + implementation 'com.github.bumptech.glide:glide:3.8.0' + implementation 'io.reactivex.rxjava2:rxjava:2.1.0' + implementation 'io.reactivex.rxjava2:rxandroid:2.0.1' + implementation 'com.google.android.exoplayer:exoplayer:r2.4.2' + implementation 'com.google.android.exoplayer:extension-okhttp:r2.4.2' + implementation 'com.github.pluscubed:recycler-fast-scroll:0.3.2@aar' + implementation 'com.facebook.stetho:stetho:1.5.0' - compile 'com.android.support:appcompat-v7:25.4.0' - compile 'com.android.support:recyclerview-v7:25.4.0' - compile 'com.android.support:design:25.4.0' + implementation 'com.android.support:appcompat-v7:25.4.0' + implementation 'com.android.support:recyclerview-v7:25.4.0' + implementation 'com.android.support:design:25.4.0' - compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { + implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true } diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/PlaybackService.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/PlaybackService.kt index e18ccbf7b..3d7e53ae7 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/PlaybackService.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/PlaybackService.kt @@ -7,19 +7,11 @@ interface PlaybackService { fun disconnect(listener: () -> Unit) fun playAll() - fun playAll(index: Int, filter: String) - - fun play( - category: String, - categoryId: Long, - index: Int, - filter: String) - + fun play(category: String, categoryId: Long, index: Int, filter: String) fun playAt(index: Int) fun pauseOrResume() - fun pause() fun resume() fun prev() diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/SystemService.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/SystemService.kt index f60f93d72..3429b4f79 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/SystemService.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/SystemService.kt @@ -28,9 +28,11 @@ import io.casey.musikcube.remote.util.Strings import io.casey.musikcube.remote.websocket.Prefs import android.support.v4.app.NotificationCompat.Action as NotifAction -/* basically a stub service that exists to keep a connection active to the -StreamingPlaybackService, which keeps music playing. TODO: should also hold -a partial wakelock to keep the radio from going to sleep. */ +/** + * a service used to interact with all of the system media-related components -- notifications, + * lock screen controls, and headset events. also holds a partial wakelock to keep the system + * from completely falling asleep during streaming playback. + */ class SystemService : Service() { private val handler = Handler() private var prefs: SharedPreferences? = null @@ -53,7 +55,6 @@ class SystemService : Service() { override fun onDestroy() { super.onDestroy() - recycleAlbumArt() unregisterReceivers() } @@ -104,34 +105,23 @@ class SystemService : Service() { private fun shutdownNow() { Log.d(TAG, "SystemService SHUT_DOWN") - if (mediaSession != null) { - mediaSession?.release() - } + mediaSession?.release() + mediaSession = null - if (playback != null) { - playback?.disconnect(playbackListener) - playback = null - } + playback?.disconnect(playbackListener) + playback = null - if (wakeLock != null) { - wakeLock?.release() - wakeLock = null - } + wakeLock?.release() + wakeLock = null stopSelf() } private fun sleepNow() { Log.d(TAG, "SystemService SLEEP") - - if (wakeLock != null) { - wakeLock?.release() - wakeLock = null - } - - if (playback != null) { - playback?.disconnect(playbackListener) - } + wakeLock?.release() + wakeLock = null + playback?.disconnect(playbackListener) } private fun initMediaSession() { @@ -140,7 +130,8 @@ class SystemService : Service() { mediaSession = MediaSessionCompat(this, "musikdroid.SystemService", receiver, null) mediaSession?.setFlags( - MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS or MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS) + MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS or + MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS) mediaSession?.setCallback(mediaSessionCallback) @@ -194,14 +185,8 @@ class SystemService : Service() { .build()) } - @Synchronized private fun recycleAlbumArt() { - if (albumArt != null) { - albumArt = null - } - } - private fun downloadAlbumArt(title: String, artist: String, album: String, duration: Int) { - recycleAlbumArt() + albumArt = null albumArtModel = AlbumArtModel(title, artist, album, AlbumArtModel.Size.Mega) { _: AlbumArtModel, url: String? -> @@ -252,7 +237,7 @@ class SystemService : Service() { currentImage = albumArt } else { - recycleAlbumArt() + albumArt = null } } @@ -427,11 +412,10 @@ class SystemService : Service() { } } } - return super.onMediaButtonEvent(mediaButtonEvent) + return false } override fun onPlay() { - super.onPlay() if (playback?.queueCount == 0) { playback?.playAll() } @@ -441,27 +425,22 @@ class SystemService : Service() { } override fun onPause() { - super.onPause() playback?.pause() } override fun onSkipToNext() { - super.onSkipToNext() playback?.next() } override fun onSkipToPrevious() { - super.onSkipToPrevious() playback?.prev() } override fun onFastForward() { - super.onFastForward() playback?.seekForward() } override fun onRewind() { - super.onRewind() playback?.seekBackward() } } diff --git a/src/musikdroid/gradle.properties b/src/musikdroid/gradle.properties index aac7c9b46..0934164d6 100644 --- a/src/musikdroid/gradle.properties +++ b/src/musikdroid/gradle.properties @@ -1,16 +1,5 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html - -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx1536m - +org.gradle.caching=true # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects