diff --git a/.idea/dictionaries/hamza.xml b/.idea/dictionaries/hamza.xml deleted file mode 100644 index 57ea2a16d..000000000 --- a/.idea/dictionaries/hamza.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - ftem - - - \ No newline at end of file diff --git a/app/src/main/assets/html/changelogs.html b/app/src/main/assets/html/changelogs.html index 23544bd04..dd67e0950 100644 --- a/app/src/main/assets/html/changelogs.html +++ b/app/src/main/assets/html/changelogs.html @@ -28,6 +28,7 @@

Bug Fixes

  • Fixed Batch Extract crashing due to special characters in app name.
  • Fixed index issue in Batch Extract.
  • Fixed changes randomly not loading properly.
  • +
  • Fixed Audio Player state not visible on third party widgets.

  • diff --git a/app/src/main/java/app/simple/inure/preferences/DevelopmentPreferences.kt b/app/src/main/java/app/simple/inure/preferences/DevelopmentPreferences.kt index e32359bc9..d38f01d80 100644 --- a/app/src/main/java/app/simple/inure/preferences/DevelopmentPreferences.kt +++ b/app/src/main/java/app/simple/inure/preferences/DevelopmentPreferences.kt @@ -105,7 +105,9 @@ object DevelopmentPreferences { DevelopmentPreferencesModel.TYPE_BOOLEAN), DevelopmentPreferencesModel("Add Bitmap To Metadata", - "Add bitmap to the metadata of MusicPlayerService. Useful for ROMs that shows Album Art on Lock Screen.", + "Add bitmap to the metadata of MusicPlayerService. " + + "Useful for ROMs that shows Album Art on Lock Screen or " + + "if widgets are not showing the album art.", ADD_BITMAP_TO_METADATA, DevelopmentPreferencesModel.TYPE_BOOLEAN), diff --git a/app/src/main/java/app/simple/inure/receivers/MediaButtonIntentReceiver.kt b/app/src/main/java/app/simple/inure/receivers/MediaButtonIntentReceiver.kt index dbab4ff1c..1e818d977 100644 --- a/app/src/main/java/app/simple/inure/receivers/MediaButtonIntentReceiver.kt +++ b/app/src/main/java/app/simple/inure/receivers/MediaButtonIntentReceiver.kt @@ -37,11 +37,11 @@ class MediaButtonIntentReceiver : BroadcastReceiver() { private const val MSG_HEADSET_DOUBLE_CLICK_TIMEOUT = 2 private const val DOUBLE_CLICK = 400 private var wakeLock: PowerManager.WakeLock? = null - private var mClickCounter = 0 - private var mLastClickTime: Long = 0 + private var clickCounter = 0 + private var lastClickTime: Long = 0 @SuppressLint("HandlerLeak") // false alarm, handler is already static - private val mHandler: Handler = object : Handler(Looper.getMainLooper()) { + private val handler: Handler = object : Handler(Looper.getMainLooper()) { override fun handleMessage(msg: Message) { when (msg.what) { MSG_HEADSET_DOUBLE_CLICK_TIMEOUT -> { @@ -90,19 +90,19 @@ class MediaButtonIntentReceiver : BroadcastReceiver() { // The service may or may not be running, but we need to send it // a command. if (keycode == KeyEvent.KEYCODE_HEADSETHOOK || keycode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { - if (eventTime - mLastClickTime >= DOUBLE_CLICK) { - mClickCounter = 0 + if (eventTime - lastClickTime >= DOUBLE_CLICK) { + clickCounter = 0 } - mClickCounter++ - if (DEBUG) Log.v(tag, "Got headset click, count = $mClickCounter") - mHandler.removeMessages(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT) - val msg: Message = mHandler.obtainMessage( - MSG_HEADSET_DOUBLE_CLICK_TIMEOUT, mClickCounter, 0, context) - val delay = if (mClickCounter < 3) DOUBLE_CLICK.toLong() else 0.toLong() - if (mClickCounter >= 3) { - mClickCounter = 0 + clickCounter++ + if (DEBUG) Log.v(tag, "Got headset click, count = $clickCounter") + handler.removeMessages(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT) + val msg: Message = handler.obtainMessage( + MSG_HEADSET_DOUBLE_CLICK_TIMEOUT, clickCounter, 0, context) + val delay = if (clickCounter < 3) DOUBLE_CLICK.toLong() else 0.toLong() + if (clickCounter >= 3) { + clickCounter = 0 } - mLastClickTime = eventTime + lastClickTime = eventTime acquireWakeLockAndSendMessage(context, msg, delay) } else { startService(context, command) @@ -141,11 +141,11 @@ class MediaButtonIntentReceiver : BroadcastReceiver() { if (DEBUG) Log.v(tag, "Acquiring wake lock and sending " + msg.what) // Make sure we don't indefinitely hold the wake lock under any circumstances wakeLock!!.acquire(10000) - mHandler.sendMessageDelayed(msg, delay) + handler.sendMessageDelayed(msg, delay) } private fun releaseWakeLockIfHandlerIdle() { - if (mHandler.hasMessages(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT)) { + if (handler.hasMessages(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT)) { if (DEBUG) Log.v(tag, "Handler still has messages pending, not releasing wake lock") return } diff --git a/app/src/main/java/app/simple/inure/services/AudioServicePager.kt b/app/src/main/java/app/simple/inure/services/AudioServicePager.kt index fb549d435..ae09d6942 100644 --- a/app/src/main/java/app/simple/inure/services/AudioServicePager.kt +++ b/app/src/main/java/app/simple/inure/services/AudioServicePager.kt @@ -287,7 +287,6 @@ class AudioServicePager : Service(), @Suppress("DEPRECATION") stopForeground(true) } - stopSelf() } @@ -304,7 +303,6 @@ class AudioServicePager : Service(), ServiceConstants.actionQuitMusicServicePager -> { quitService() } - else -> { /* no-op */ } @@ -312,41 +310,9 @@ class AudioServicePager : Service(), } }) + mediaSessionCompat!!.isActive = true mediaSessionCompat!!.setMediaButtonReceiver(mediaButtonReceiverPendingIntent) mediaControllerCompat = mediaSessionCompat!!.controller - // mediaMetadataCompat = mediaControllerCompat!!.metadata - } - - private fun setPlaybackState(playbackState: Int) { - mediaSessionCompat?.setPlaybackState( - PlaybackStateCompat.Builder() - .setState(playbackState, mediaPlayer.currentPosition.toLong(), 1f) - .setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE or - PlaybackStateCompat.ACTION_PLAY or - PlaybackStateCompat.ACTION_PAUSE or - PlaybackStateCompat.ACTION_SKIP_TO_NEXT or - PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS or - PlaybackStateCompat.ACTION_SEEK_TO or - PlaybackStateCompat.ACTION_STOP) - .addCustomAction( - PlaybackStateCompat.CustomAction.Builder( - ServiceConstants.actionQuitMusicServicePager, - "Close", - R.drawable.ic_close - ).build()) - .build()) - } - - private fun quitService() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - stopForeground(STOP_FOREGROUND_REMOVE) - } else { - @Suppress("DEPRECATION") - stopForeground(true) - } - - IntentHelper.sendLocalBroadcastIntent(ServiceConstants.actionQuitMusicServicePager, applicationContext) - stopSelf() } private fun setupMetadata() { @@ -369,7 +335,6 @@ class AudioServicePager : Service(), } withContext(Dispatchers.Main) { - // setupMediaSession() mediaSessionCompat?.setMetadata(mediaMetadataCompat) createNotificationChannel() setPlayingState() @@ -382,6 +347,38 @@ class AudioServicePager : Service(), } } + private fun setPlaybackState(playbackState: Int) { + mediaSessionCompat?.setPlaybackState( + PlaybackStateCompat.Builder() + .setState(playbackState, mediaPlayer.currentPosition.toLong(), 1f) + .setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE or + PlaybackStateCompat.ACTION_PLAY or + PlaybackStateCompat.ACTION_PAUSE or + PlaybackStateCompat.ACTION_SKIP_TO_NEXT or + PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS or + PlaybackStateCompat.ACTION_SEEK_TO or + PlaybackStateCompat.ACTION_STOP) + .addCustomAction( + PlaybackStateCompat.CustomAction.Builder( + ServiceConstants.actionQuitMusicServicePager, + "Close", + R.drawable.ic_close + ).build()) + .build()) + } + + private fun quitService() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + stopForeground(STOP_FOREGROUND_REMOVE) + } else { + @Suppress("DEPRECATION") + stopForeground(true) + } + + IntentHelper.sendLocalBroadcastIntent(ServiceConstants.actionQuitMusicServicePager, applicationContext) + stopSelf() + } + private fun requestAudioFocus(): Boolean { val value: Int if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {