Skip to content

Commit

Permalink
Merge remote-tracking branch 'main/dev' into dev
Browse files Browse the repository at this point in the history
Signed-off-by: Muntashir Al-Islam <[email protected]>
  • Loading branch information
MuntashirAkon committed Apr 3, 2023
2 parents 2c9547c + eb4876a commit bfa08fc
Show file tree
Hide file tree
Showing 112 changed files with 1,947 additions and 2,057 deletions.
21 changes: 11 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ android {

defaultConfig {
minSdk 21
targetSdk 32
targetSdk 33

vectorDrawables.useSupportLibrary = true

applicationId 'io.github.muntashirakon.Music'
versionCode 10600
versionName '6.0.4'
versionCode 10603
versionName '6.1.0'

multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix '.debug'
Expand Down Expand Up @@ -72,13 +73,13 @@ dependencies {
implementation "androidx.core:core-ktx:$core_version"
implementation 'androidx.palette:palette-ktx:1.0.0'

implementation "androidx.media:media:1.6.0"
implementation 'androidx.mediarouter:mediarouter:1.3.1'

implementation "androidx.navigation:navigation-runtime-ktx:$navigation_version"
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"

def room_version = '2.5.0'
def room_version = '2.5.1'
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
ksp "androidx.room:room-compiler:$room_version"
Expand All @@ -104,11 +105,11 @@ dependencies {

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"

def koin_version = '3.3.3'
def koin_version = '3.4.0'
implementation "io.insert-koin:koin-core:$koin_version"
implementation "io.insert-koin:koin-android:$koin_version"

def glide_version = '4.15.0'
def glide_version = '4.15.1'
implementation "com.github.bumptech.glide:glide:$glide_version"
ksp "com.github.bumptech.glide:ksp:$glide_version"

Expand All @@ -127,5 +128,5 @@ dependencies {
implementation 'com.github.dhaval2404:imagepicker:2.1'
implementation 'me.zhanghai.android.fastscroll:library:1.2.0'
implementation 'cat.ereza:customactivityoncrash:2.4.0'
implementation 'me.tankery.lib:circularSeekBar:1.4.1'
implementation 'me.tankery.lib:circularSeekBar:1.4.2'
}
22 changes: 19 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
Expand All @@ -30,16 +34,19 @@
<application
android:name=".App"
android:allowBackup="@bool/allowBackup"
android:appCategory="audio"
android:configChanges="locale|layoutDirection"
android:enableOnBackInvokedCallback="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:localeConfig="@xml/locales_config"
android:requestLegacyExternalStorage="true"
android:restoreAnyVersion="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.RetroMusic.FollowSystem"
android:usesCleartextTraffic="true"
tools:targetApi="m">
tools:ignore="UnusedAttribute">
<activity
android:name=".activities.MainActivity"
android:exported="true"
Expand Down Expand Up @@ -295,7 +302,6 @@

<service
android:name=".service.MusicService"
android:enabled="true"
android:exported="true"
android:foregroundServiceType="mediaPlayback"
android:label="@string/app_name">
Expand All @@ -322,6 +328,16 @@
<meta-data
android:name="com.google.android.gms.car.notification.SmallIcon"
android:resource="@drawable/ic_notification" />

<!-- For auto-storage of locale on Android 12 and lower -->
<service
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
android:enabled="false"
android:exported="false">
<meta-data
android:name="autoStoreLocales"
android:value="true" />
</service>
</application>

<!--
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/assets/retro-changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@

<body>

<div>
<h5>March 30, 2023</h5>
<h2>v6.1.0</h2>
<h3>What's New</h3>
<ul>
<li>App now targets Android 13, support for Granular media permissions, Photo picker, Per-app language preferences & Predictive back gesture</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Fixed playlist reordering crash</li>
<li>Other minor bugs fixes and improvements</li>
</ul>
</div>
<div>
<h5>March 13, 2023</h5>
<h2>v6.0.4</h2>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/code/name/monkey/retromusic/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const val ALBUM_COVER_STYLE = "album_cover_style_id"
const val ALBUM_COVER_TRANSFORM = "album_cover_transform"
const val TAB_TEXT_MODE = "tab_text_mode"
const val LANGUAGE_NAME = "language_name"
const val LOCALE_AUTO_STORE_ENABLED = "locale_auto_store_enabled"
const val SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_song"
const val ALBUM_GRID_STYLE = "album_grid_style_home"
const val ARTIST_GRID_STYLE = "artist_grid_style_home"
Expand All @@ -110,7 +111,6 @@ const val ARTIST_GRID_SIZE_LAND = "artist_grid_size_land"
const val PLAYLIST_GRID_SIZE = "playlist_grid_size"
const val PLAYLIST_GRID_SIZE_LAND = "playlist_grid_size_land"
const val COLORED_APP_SHORTCUTS = "colored_app_shortcuts"
const val AUDIO_DUCKING = "audio_ducking"
const val LAST_ADDED_CUTOFF = "last_added_interval"
const val LAST_SLEEP_TIMER_VALUE = "last_sleep_timer_value"
const val NEXT_SLEEP_TIMER_ELAPSED_REALTIME = "next_sleep_timer_elapsed_real_time"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package code.name.monkey.retromusic
import androidx.room.Room
import code.name.monkey.retromusic.auto.AutoMusicProvider
import code.name.monkey.retromusic.db.MIGRATION_23_24
import code.name.monkey.retromusic.db.PlaylistWithSongs
import code.name.monkey.retromusic.db.RetroDatabase
import code.name.monkey.retromusic.fragments.LibraryViewModel
import code.name.monkey.retromusic.fragments.albums.AlbumDetailsViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
package code.name.monkey.retromusic.activities

import android.Manifest
import android.Manifest.permission.BLUETOOTH_CONNECT
import android.content.Intent
import android.content.pm.PackageManager
Expand Down Expand Up @@ -127,10 +126,7 @@ class PermissionActivity : AbsMusicServiceActivity() {
}

private fun hasStoragePermission(): Boolean {
return ActivityCompat.checkSelfPermission(
this,
Manifest.permission.READ_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED
return hasPermissions()
}

@RequiresApi(Build.VERSION_CODES.S)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import android.view.ViewGroup
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.core.content.PackageManagerCompat
import androidx.core.content.pm.PackageInfoCompat
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.FragmentActivity
Expand All @@ -27,7 +26,7 @@ import code.name.monkey.retromusic.extensions.openUrl
import code.name.monkey.retromusic.util.PreferenceUtil.lastVersion
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import java.nio.charset.StandardCharsets
import java.util.Locale
import java.util.*

class WhatsNewFragment : BottomSheetDialogFragment() {
private var _binding: FragmentWhatsNewBinding? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import android.Manifest
import android.content.*
import android.os.Bundle
import android.os.IBinder
import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.R
Expand Down Expand Up @@ -96,8 +97,7 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventLi
filter.addAction(MEDIA_STORE_CHANGED)
filter.addAction(FAVORITE_STATE_CHANGED)

registerReceiver(musicStateReceiver, filter)

ContextCompat.registerReceiver(this, musicStateReceiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED)
receiverRegistered = true
}

Expand All @@ -122,23 +122,14 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventLi
listener.onPlayingMetaChanged()
}
lifecycleScope.launch(Dispatchers.IO) {
val entity = repository.songPresentInHistory(MusicPlayerRemote.currentSong)
if (entity != null) {
repository.updateHistorySong(MusicPlayerRemote.currentSong)
} else {
// Check whether pause history option is ON or OFF
if (!PreferenceUtil.pauseHistory) {
repository.addSongToHistory(MusicPlayerRemote.currentSong)
}
}
val songs = repository.checkSongExistInPlayCount(MusicPlayerRemote.currentSong.id)
if (songs.isNotEmpty()) {
repository.updateSongInPlayCount(songs.first().apply {
playCount += 1
})
} else {
repository.insertSongInPlayCount(MusicPlayerRemote.currentSong.toPlayCount())
if (!PreferenceUtil.pauseHistory) {
repository.upsertSongInHistory(MusicPlayerRemote.currentSong)
}
val song = repository.findSongExistInPlayCount(MusicPlayerRemote.currentSong.id)
?.apply { playCount += 1 }
?: MusicPlayerRemote.currentSong.toPlayCount()

repository.upsertSongInPlayCount(song)
}
}

Expand Down Expand Up @@ -190,7 +181,13 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventLi
}

override fun getPermissionsToRequest(): Array<String> {
return mutableListOf(Manifest.permission.READ_EXTERNAL_STORAGE).apply {
return mutableListOf<String>().apply {
if (VersionUtils.hasT()) {
add(Manifest.permission.READ_MEDIA_AUDIO)
add(Manifest.permission.POST_NOTIFICATIONS)
} else {
add(Manifest.permission.READ_EXTERNAL_STORAGE)
}
if (!VersionUtils.hasR()) {
add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
private var navigationBarColorAnimator: ValueAnimator? = null
private val argbEvaluator: ArgbEvaluator = ArgbEvaluator()

private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
println("Handle back press ${bottomSheetBehavior.state}")
if (!handleBackPress()) {
remove()
onBackPressedDispatcher.onBackPressed()
}
}
}

private val bottomSheetCallbackList by lazy {
object : BottomSheetCallback() {

Expand All @@ -133,6 +143,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
}

override fun onStateChanged(bottomSheet: View, newState: Int) {
onBackPressedCallback.isEnabled = newState == STATE_EXPANDED
when (newState) {
STATE_EXPANDED -> {
onPanelExpanded()
Expand Down Expand Up @@ -191,6 +202,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
}

navigationBarColor = surfaceColor()

onBackPressedDispatcher.addCallback(onBackPressedCallback)
}

private fun setupBottomSheet() {
Expand Down Expand Up @@ -374,7 +387,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
}

private fun handleBackPress(): Boolean {
if (bottomSheetBehavior.peekHeight != 0 && playerFragment.onBackPressed()) return true
if (panelState == STATE_EXPANDED) {
collapsePanel()
return true
Expand Down
Loading

0 comments on commit bfa08fc

Please sign in to comment.