Skip to content

Commit bfa08fc

Browse files
committed
Merge remote-tracking branch 'main/dev' into dev
Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
2 parents 2c9547c + eb4876a commit bfa08fc

File tree

112 files changed

+1947
-2057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+1947
-2057
lines changed

app/build.gradle

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ android {
1010

1111
defaultConfig {
1212
minSdk 21
13-
targetSdk 32
13+
targetSdk 33
1414

1515
vectorDrawables.useSupportLibrary = true
1616

1717
applicationId 'io.github.muntashirakon.Music'
18-
versionCode 10600
19-
versionName '6.0.4'
18+
versionCode 10603
19+
versionName '6.1.0'
2020

2121
multiDexEnabled true
2222
}
2323
buildTypes {
2424
release {
25-
minifyEnabled false
26-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25+
shrinkResources true
26+
minifyEnabled true
27+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2728
}
2829
debug {
2930
applicationIdSuffix '.debug'
@@ -72,13 +73,13 @@ dependencies {
7273
implementation "androidx.core:core-ktx:$core_version"
7374
implementation 'androidx.palette:palette-ktx:1.0.0'
7475

75-
implementation "androidx.media:media:1.6.0"
76+
implementation 'androidx.mediarouter:mediarouter:1.3.1'
7677

7778
implementation "androidx.navigation:navigation-runtime-ktx:$navigation_version"
7879
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
7980
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
8081

81-
def room_version = '2.5.0'
82+
def room_version = '2.5.1'
8283
implementation "androidx.room:room-runtime:$room_version"
8384
implementation "androidx.room:room-ktx:$room_version"
8485
ksp "androidx.room:room-compiler:$room_version"
@@ -104,11 +105,11 @@ dependencies {
104105

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

107-
def koin_version = '3.3.3'
108+
def koin_version = '3.4.0'
108109
implementation "io.insert-koin:koin-core:$koin_version"
109110
implementation "io.insert-koin:koin-android:$koin_version"
110111

111-
def glide_version = '4.15.0'
112+
def glide_version = '4.15.1'
112113
implementation "com.github.bumptech.glide:glide:$glide_version"
113114
ksp "com.github.bumptech.glide:ksp:$glide_version"
114115

@@ -127,5 +128,5 @@ dependencies {
127128
implementation 'com.github.dhaval2404:imagepicker:2.1'
128129
implementation 'me.zhanghai.android.fastscroll:library:1.2.0'
129130
implementation 'cat.ereza:customactivityoncrash:2.4.0'
130-
implementation 'me.tankery.lib:circularSeekBar:1.4.1'
131+
implementation 'me.tankery.lib:circularSeekBar:1.4.2'
131132
}

app/src/main/AndroidManifest.xml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
1212
<uses-permission android:name="android.permission.VIBRATE" />
1313
<uses-permission android:name="android.permission.WAKE_LOCK" />
14-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
14+
<uses-permission
15+
android:name="android.permission.READ_EXTERNAL_STORAGE"
16+
android:maxSdkVersion="32" />
17+
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
18+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
1519
<uses-permission
1620
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
1721
android:maxSdkVersion="29" />
@@ -30,16 +34,19 @@
3034
<application
3135
android:name=".App"
3236
android:allowBackup="@bool/allowBackup"
37+
android:appCategory="audio"
3338
android:configChanges="locale|layoutDirection"
39+
android:enableOnBackInvokedCallback="true"
3440
android:icon="@mipmap/ic_launcher"
3541
android:label="@string/app_name"
42+
android:localeConfig="@xml/locales_config"
3643
android:requestLegacyExternalStorage="true"
3744
android:restoreAnyVersion="true"
3845
android:roundIcon="@mipmap/ic_launcher_round"
3946
android:supportsRtl="true"
4047
android:theme="@style/Theme.RetroMusic.FollowSystem"
4148
android:usesCleartextTraffic="true"
42-
tools:targetApi="m">
49+
tools:ignore="UnusedAttribute">
4350
<activity
4451
android:name=".activities.MainActivity"
4552
android:exported="true"
@@ -295,7 +302,6 @@
295302

296303
<service
297304
android:name=".service.MusicService"
298-
android:enabled="true"
299305
android:exported="true"
300306
android:foregroundServiceType="mediaPlayback"
301307
android:label="@string/app_name">
@@ -322,6 +328,16 @@
322328
<meta-data
323329
android:name="com.google.android.gms.car.notification.SmallIcon"
324330
android:resource="@drawable/ic_notification" />
331+
332+
<!-- For auto-storage of locale on Android 12 and lower -->
333+
<service
334+
android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
335+
android:enabled="false"
336+
android:exported="false">
337+
<meta-data
338+
android:name="autoStoreLocales"
339+
android:value="true" />
340+
</service>
325341
</application>
326342

327343
<!--

app/src/main/assets/retro-changelog.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@
6363

6464
<body>
6565

66+
<div>
67+
<h5>March 30, 2023</h5>
68+
<h2>v6.1.0</h2>
69+
<h3>What's New</h3>
70+
<ul>
71+
<li>App now targets Android 13, support for Granular media permissions, Photo picker, Per-app language preferences & Predictive back gesture</li>
72+
</ul>
73+
<h3>Fixed</h3>
74+
<ul>
75+
<li>Fixed playlist reordering crash</li>
76+
<li>Other minor bugs fixes and improvements</li>
77+
</ul>
78+
</div>
6679
<div>
6780
<h5>March 13, 2023</h5>
6881
<h2>v6.0.4</h2>

app/src/main/java/code/name/monkey/retromusic/Constants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const val ALBUM_COVER_STYLE = "album_cover_style_id"
8787
const val ALBUM_COVER_TRANSFORM = "album_cover_transform"
8888
const val TAB_TEXT_MODE = "tab_text_mode"
8989
const val LANGUAGE_NAME = "language_name"
90+
const val LOCALE_AUTO_STORE_ENABLED = "locale_auto_store_enabled"
9091
const val SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_song"
9192
const val ALBUM_GRID_STYLE = "album_grid_style_home"
9293
const val ARTIST_GRID_STYLE = "artist_grid_style_home"
@@ -110,7 +111,6 @@ const val ARTIST_GRID_SIZE_LAND = "artist_grid_size_land"
110111
const val PLAYLIST_GRID_SIZE = "playlist_grid_size"
111112
const val PLAYLIST_GRID_SIZE_LAND = "playlist_grid_size_land"
112113
const val COLORED_APP_SHORTCUTS = "colored_app_shortcuts"
113-
const val AUDIO_DUCKING = "audio_ducking"
114114
const val LAST_ADDED_CUTOFF = "last_added_interval"
115115
const val LAST_SLEEP_TIMER_VALUE = "last_sleep_timer_value"
116116
const val NEXT_SLEEP_TIMER_ELAPSED_REALTIME = "next_sleep_timer_elapsed_real_time"

app/src/main/java/code/name/monkey/retromusic/LanguageContextWrapper.kt

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/src/main/java/code/name/monkey/retromusic/MainModule.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package code.name.monkey.retromusic
33
import androidx.room.Room
44
import code.name.monkey.retromusic.auto.AutoMusicProvider
55
import code.name.monkey.retromusic.db.MIGRATION_23_24
6-
import code.name.monkey.retromusic.db.PlaylistWithSongs
76
import code.name.monkey.retromusic.db.RetroDatabase
87
import code.name.monkey.retromusic.fragments.LibraryViewModel
98
import code.name.monkey.retromusic.fragments.albums.AlbumDetailsViewModel

app/src/main/java/code/name/monkey/retromusic/activities/PermissionActivity.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
package code.name.monkey.retromusic.activities
1616

17-
import android.Manifest
1817
import android.Manifest.permission.BLUETOOTH_CONNECT
1918
import android.content.Intent
2019
import android.content.pm.PackageManager
@@ -127,10 +126,7 @@ class PermissionActivity : AbsMusicServiceActivity() {
127126
}
128127

129128
private fun hasStoragePermission(): Boolean {
130-
return ActivityCompat.checkSelfPermission(
131-
this,
132-
Manifest.permission.READ_EXTERNAL_STORAGE
133-
) == PackageManager.PERMISSION_GRANTED
129+
return hasPermissions()
134130
}
135131

136132
@RequiresApi(Build.VERSION_CODES.S)

app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewFragment.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import android.view.ViewGroup
1111
import android.webkit.WebResourceRequest
1212
import android.webkit.WebView
1313
import android.webkit.WebViewClient
14-
import androidx.core.content.PackageManagerCompat
1514
import androidx.core.content.pm.PackageInfoCompat
1615
import androidx.core.widget.NestedScrollView
1716
import androidx.fragment.app.FragmentActivity
@@ -27,7 +26,7 @@ import code.name.monkey.retromusic.extensions.openUrl
2726
import code.name.monkey.retromusic.util.PreferenceUtil.lastVersion
2827
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
2928
import java.nio.charset.StandardCharsets
30-
import java.util.Locale
29+
import java.util.*
3130

3231
class WhatsNewFragment : BottomSheetDialogFragment() {
3332
private var _binding: FragmentWhatsNewBinding? = null

app/src/main/java/code/name/monkey/retromusic/activities/base/AbsMusicServiceActivity.kt

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import android.Manifest
1818
import android.content.*
1919
import android.os.Bundle
2020
import android.os.IBinder
21+
import androidx.core.content.ContextCompat
2122
import androidx.lifecycle.lifecycleScope
2223
import code.name.monkey.appthemehelper.util.VersionUtils
2324
import code.name.monkey.retromusic.R
@@ -96,8 +97,7 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventLi
9697
filter.addAction(MEDIA_STORE_CHANGED)
9798
filter.addAction(FAVORITE_STATE_CHANGED)
9899

99-
registerReceiver(musicStateReceiver, filter)
100-
100+
ContextCompat.registerReceiver(this, musicStateReceiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED)
101101
receiverRegistered = true
102102
}
103103

@@ -122,23 +122,14 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventLi
122122
listener.onPlayingMetaChanged()
123123
}
124124
lifecycleScope.launch(Dispatchers.IO) {
125-
val entity = repository.songPresentInHistory(MusicPlayerRemote.currentSong)
126-
if (entity != null) {
127-
repository.updateHistorySong(MusicPlayerRemote.currentSong)
128-
} else {
129-
// Check whether pause history option is ON or OFF
130-
if (!PreferenceUtil.pauseHistory) {
131-
repository.addSongToHistory(MusicPlayerRemote.currentSong)
132-
}
133-
}
134-
val songs = repository.checkSongExistInPlayCount(MusicPlayerRemote.currentSong.id)
135-
if (songs.isNotEmpty()) {
136-
repository.updateSongInPlayCount(songs.first().apply {
137-
playCount += 1
138-
})
139-
} else {
140-
repository.insertSongInPlayCount(MusicPlayerRemote.currentSong.toPlayCount())
125+
if (!PreferenceUtil.pauseHistory) {
126+
repository.upsertSongInHistory(MusicPlayerRemote.currentSong)
141127
}
128+
val song = repository.findSongExistInPlayCount(MusicPlayerRemote.currentSong.id)
129+
?.apply { playCount += 1 }
130+
?: MusicPlayerRemote.currentSong.toPlayCount()
131+
132+
repository.upsertSongInPlayCount(song)
142133
}
143134
}
144135

@@ -190,7 +181,13 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventLi
190181
}
191182

192183
override fun getPermissionsToRequest(): Array<String> {
193-
return mutableListOf(Manifest.permission.READ_EXTERNAL_STORAGE).apply {
184+
return mutableListOf<String>().apply {
185+
if (VersionUtils.hasT()) {
186+
add(Manifest.permission.READ_MEDIA_AUDIO)
187+
add(Manifest.permission.POST_NOTIFICATIONS)
188+
} else {
189+
add(Manifest.permission.READ_EXTERNAL_STORAGE)
190+
}
194191
if (!VersionUtils.hasR()) {
195192
add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
196193
}

app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
117117
private var navigationBarColorAnimator: ValueAnimator? = null
118118
private val argbEvaluator: ArgbEvaluator = ArgbEvaluator()
119119

120+
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
121+
override fun handleOnBackPressed() {
122+
println("Handle back press ${bottomSheetBehavior.state}")
123+
if (!handleBackPress()) {
124+
remove()
125+
onBackPressedDispatcher.onBackPressed()
126+
}
127+
}
128+
}
129+
120130
private val bottomSheetCallbackList by lazy {
121131
object : BottomSheetCallback() {
122132

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

135145
override fun onStateChanged(bottomSheet: View, newState: Int) {
146+
onBackPressedCallback.isEnabled = newState == STATE_EXPANDED
136147
when (newState) {
137148
STATE_EXPANDED -> {
138149
onPanelExpanded()
@@ -191,6 +202,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
191202
}
192203

193204
navigationBarColor = surfaceColor()
205+
206+
onBackPressedDispatcher.addCallback(onBackPressedCallback)
194207
}
195208

196209
private fun setupBottomSheet() {
@@ -374,7 +387,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
374387
}
375388

376389
private fun handleBackPress(): Boolean {
377-
if (bottomSheetBehavior.peekHeight != 0 && playerFragment.onBackPressed()) return true
378390
if (panelState == STATE_EXPANDED) {
379391
collapsePanel()
380392
return true

0 commit comments

Comments
 (0)