updating commons and target SDK to 31

This commit is contained in:
tibbi 2022-04-03 13:55:26 +02:00
parent 6fc4511a14
commit df23bff406
19 changed files with 78 additions and 40 deletions

View file

@ -10,12 +10,12 @@ if (keystorePropertiesFile.exists()) {
}
android {
compileSdkVersion 30
compileSdkVersion 31
defaultConfig {
applicationId "com.simplemobiletools.musicplayer"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 31
versionCode 95
versionName "5.10.1"
setProperty("archivesBaseName", "music-player")
@ -68,7 +68,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:c3c88596e0'
implementation 'com.github.SimpleMobileTools:Simple-Commons:8301d8356c'
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'androidx.media:media:1.4.3'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

View file

@ -33,10 +33,12 @@
<activity
android:name=".activities.SplashActivity"
android:exported="false"
android:theme="@style/SplashTheme" />
<activity
android:name=".activities.MainActivity"
android:exported="true"
android:launchMode="singleTask">
<meta-data
android:name="android.app.default_searchable"
@ -49,6 +51,7 @@
<activity
android:name=".activities.WidgetConfigureActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/MyWidgetConfigTheme">
<intent-filter>
@ -58,36 +61,49 @@
<activity
android:name="com.simplemobiletools.commons.activities.AboutActivity"
android:exported="false"
android:label="@string/about"
android:parentActivityName=".activities.MainActivity" />
<activity
android:name="com.simplemobiletools.commons.activities.CustomizationActivity"
android:exported="false"
android:label="@string/customize_colors"
android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name=".activities.SettingsActivity"
android:exported="true"
android:label="@string/settings"
android:parentActivityName=".activities.MainActivity" />
android:parentActivityName=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".activities.EqualizerActivity"
android:exported="false"
android:label="@string/equalizer"
android:parentActivityName=".activities.MainActivity" />
<activity
android:name=".activities.AlbumsActivity"
android:exported="false"
android:label="@string/artist"
android:parentActivityName=".activities.MainActivity" />
<activity
android:name=".activities.TracksActivity"
android:exported="false"
android:label="@string/artist"
android:parentActivityName=".activities.AlbumsActivity" />
<activity
android:name=".activities.TrackActivity"
android:exported="true"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/TranslucentTheme">
@ -117,12 +133,13 @@
<activity
android:name=".activities.QueueActivity"
android:exported="false"
android:label="@string/track_queue"
android:parentActivityName=".activities.TrackActivity" />
<service
android:name=".services.MusicService"
android:exported="false">
android:exported="true">
<intent-filter>
<action android:name="com.simplemobiletools.musicplayer.action.INIT" />
<action android:name="com.simplemobiletools.musicplayer.action.INIT_PATH" />
@ -148,6 +165,7 @@
<receiver
android:name=".helpers.MyWidgetProvider"
android:exported="true"
android:icon="@drawable/img_widget_preview">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
@ -167,13 +185,17 @@
</intent-filter>
</receiver>
<receiver android:name=".receivers.HeadsetPlugReceiver">
<receiver
android:name=".receivers.HeadsetPlugReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.ACTION_HEADSET_PLUG" />
</intent-filter>
</receiver>
<receiver android:name=".receivers.ControlActionsListener" />
<receiver
android:name=".receivers.ControlActionsListener"
android:exported="false" />
<receiver
android:name=".receivers.NotificationDismissedReceiver"
@ -197,6 +219,7 @@
<activity-alias
android:name=".activities.SplashActivity.Red"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_red"
android:roundIcon="@mipmap/ic_launcher_red"
android:targetActivity=".activities.SplashActivity">
@ -210,6 +233,7 @@
<activity-alias
android:name=".activities.SplashActivity.Pink"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_pink"
android:roundIcon="@mipmap/ic_launcher_pink"
android:targetActivity=".activities.SplashActivity">
@ -223,6 +247,7 @@
<activity-alias
android:name=".activities.SplashActivity.Purple"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_purple"
android:roundIcon="@mipmap/ic_launcher_purple"
android:targetActivity=".activities.SplashActivity">
@ -236,6 +261,7 @@
<activity-alias
android:name=".activities.SplashActivity.Deep_purple"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_deep_purple"
android:roundIcon="@mipmap/ic_launcher_deep_purple"
android:targetActivity=".activities.SplashActivity">
@ -249,6 +275,7 @@
<activity-alias
android:name=".activities.SplashActivity.Indigo"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_indigo"
android:roundIcon="@mipmap/ic_launcher_indigo"
android:targetActivity=".activities.SplashActivity">
@ -262,6 +289,7 @@
<activity-alias
android:name=".activities.SplashActivity.Blue"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_blue"
android:roundIcon="@mipmap/ic_launcher_blue"
android:targetActivity=".activities.SplashActivity">
@ -275,6 +303,7 @@
<activity-alias
android:name=".activities.SplashActivity.Light_blue"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_light_blue"
android:roundIcon="@mipmap/ic_launcher_light_blue"
android:targetActivity=".activities.SplashActivity">
@ -288,6 +317,7 @@
<activity-alias
android:name=".activities.SplashActivity.Cyan"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_cyan"
android:roundIcon="@mipmap/ic_launcher_cyan"
android:targetActivity=".activities.SplashActivity">
@ -301,6 +331,7 @@
<activity-alias
android:name=".activities.SplashActivity.Teal"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_teal"
android:roundIcon="@mipmap/ic_launcher_teal"
android:targetActivity=".activities.SplashActivity">
@ -314,6 +345,7 @@
<activity-alias
android:name=".activities.SplashActivity.Green"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_green"
android:roundIcon="@mipmap/ic_launcher_green"
android:targetActivity=".activities.SplashActivity">
@ -327,6 +359,7 @@
<activity-alias
android:name=".activities.SplashActivity.Light_green"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_light_green"
android:roundIcon="@mipmap/ic_launcher_light_green"
android:targetActivity=".activities.SplashActivity">
@ -340,6 +373,7 @@
<activity-alias
android:name=".activities.SplashActivity.Lime"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_lime"
android:roundIcon="@mipmap/ic_launcher_lime"
android:targetActivity=".activities.SplashActivity">
@ -353,6 +387,7 @@
<activity-alias
android:name=".activities.SplashActivity.Yellow"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_yellow"
android:roundIcon="@mipmap/ic_launcher_yellow"
android:targetActivity=".activities.SplashActivity">
@ -366,6 +401,7 @@
<activity-alias
android:name=".activities.SplashActivity.Amber"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_amber"
android:roundIcon="@mipmap/ic_launcher_amber"
android:targetActivity=".activities.SplashActivity">
@ -379,6 +415,7 @@
<activity-alias
android:name=".activities.SplashActivity.Orange"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:targetActivity=".activities.SplashActivity">
@ -391,6 +428,7 @@
<activity-alias
android:name=".activities.SplashActivity.Deep_orange"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_deep_orange"
android:roundIcon="@mipmap/ic_launcher_deep_orange"
android:targetActivity=".activities.SplashActivity">
@ -404,6 +442,7 @@
<activity-alias
android:name=".activities.SplashActivity.Brown"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_brown"
android:roundIcon="@mipmap/ic_launcher_brown"
android:targetActivity=".activities.SplashActivity">
@ -417,6 +456,7 @@
<activity-alias
android:name=".activities.SplashActivity.Blue_grey"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_blue_grey"
android:roundIcon="@mipmap/ic_launcher_blue_grey"
android:targetActivity=".activities.SplashActivity">
@ -430,6 +470,7 @@
<activity-alias
android:name=".activities.SplashActivity.Grey_black"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_grey_black"
android:roundIcon="@mipmap/ic_launcher_grey_black"
android:targetActivity=".activities.SplashActivity">

View file

@ -6,8 +6,8 @@ import android.view.Menu
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getFormattedDuration
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
import com.simplemobiletools.commons.extensions.hideKeyboard
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.adapters.AlbumsTracksAdapter
@ -37,7 +37,7 @@ class AlbumsActivity : SimpleActivity() {
bus = EventBus.getDefault()
bus!!.register(this)
albums_fastscroller.updateColors(getAdjustedPrimaryColor())
albums_fastscroller.updateColors(getProperPrimaryColor())
val artistType = object : TypeToken<Artist>() {}.type
val artist = Gson().fromJson<Artist>(intent.getStringExtra(ARTIST), artistType)

View file

@ -86,7 +86,7 @@ class MainActivity : SimpleActivity() {
sleep_timer_stop.applyColorFilter(config.textColor)
updateCurrentTrackBar()
val adjustedPrimaryColor = getAdjustedPrimaryColor()
val adjustedPrimaryColor = getProperPrimaryColor()
main_tabs_holder.apply {
setTabTextColors(config.textColor, adjustedPrimaryColor)
setSelectedTabIndicatorColor(adjustedPrimaryColor)

View file

@ -5,8 +5,7 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getContrastColor
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.adapters.QueueAdapter
@ -33,7 +32,7 @@ class QueueActivity : SimpleActivity() {
bus = EventBus.getDefault()
bus!!.register(this)
setupAdapter()
queue_fastscroller.updateColors(getAdjustedPrimaryColor())
queue_fastscroller.updateColors(getProperPrimaryColor())
}
override fun onDestroy() {

View file

@ -38,11 +38,11 @@ class SettingsActivity : SimpleActivity() {
invalidateOptionsMenu()
arrayOf(settings_color_customization_label, settings_general_settings_label).forEach {
it.setTextColor(getAdjustedPrimaryColor())
it.setTextColor(getProperPrimaryColor())
}
arrayOf(settings_color_customization_holder, settings_general_settings_holder).forEach {
it.background.applyColorFilter(baseConfig.backgroundColor.getContrastColor())
it.background.applyColorFilter(getProperBackgroundColor().getContrastColor())
}
}

View file

@ -2,7 +2,7 @@ package com.simplemobiletools.musicplayer.activities
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.*
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
@ -304,7 +304,7 @@ class TrackActivity : SimpleActivity(), PlaybackSpeedListener {
private fun setupShuffleButton() {
val isShuffleEnabled = config.isShuffleEnabled
activity_track_toggle_shuffle.apply {
applyColorFilter(if (isShuffleEnabled) getAdjustedPrimaryColor() else config.textColor)
applyColorFilter(if (isShuffleEnabled) getProperPrimaryColor() else config.textColor)
alpha = if (isShuffleEnabled) 1f else MEDIUM_ALPHA
contentDescription = getString(if (isShuffleEnabled) R.string.disable_shuffle else R.string.enable_shuffle)
}
@ -328,7 +328,7 @@ class TrackActivity : SimpleActivity(), PlaybackSpeedListener {
val isRepeatOff = playbackSetting == PlaybackSetting.REPEAT_OFF
alpha = if (isRepeatOff) MEDIUM_ALPHA else 1f
applyColorFilter(if (isRepeatOff) config.textColor else getAdjustedPrimaryColor())
applyColorFilter(if (isRepeatOff) config.textColor else getProperPrimaryColor())
}
}

View file

@ -73,7 +73,7 @@ class TracksActivity : SimpleActivity() {
val titleToUse = playlist?.title ?: album?.title ?: folder ?: ""
title = titleToUse.replace("<", "&lt;")
val adjustedPrimaryColor = getAdjustedPrimaryColor()
val adjustedPrimaryColor = getProperPrimaryColor()
tracks_fastscroller.updateColors(adjustedPrimaryColor)
tracks_placeholder.setTextColor(config.textColor)
tracks_placeholder_2.setTextColor(adjustedPrimaryColor)

View file

@ -20,7 +20,6 @@ import com.simplemobiletools.musicplayer.extensions.*
import com.simplemobiletools.musicplayer.models.Album
import com.simplemobiletools.musicplayer.models.Track
import kotlinx.android.synthetic.main.item_album.view.*
import java.util.*
class AlbumsAdapter(activity: SimpleActivity, var albums: ArrayList<Album>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
@ -151,7 +150,7 @@ class AlbumsAdapter(activity: SimpleActivity, var albums: ArrayList<Album>, recy
private fun setupView(view: View, album: Album) {
view.apply {
album_frame?.isSelected = selectedKeys.contains(album.hashCode())
album_title.text = if (textToHighlight.isEmpty()) album.title else album.title.highlightTextPart(textToHighlight, adjustedPrimaryColor)
album_title.text = if (textToHighlight.isEmpty()) album.title else album.title.highlightTextPart(textToHighlight, properPrimaryColor)
album_title.setTextColor(textColor)
val tracks = resources.getQuantityString(R.plurals.tracks_plural, album.trackCnt, album.trackCnt)

View file

@ -159,7 +159,7 @@ class ArtistsAdapter(activity: SimpleActivity, var artists: ArrayList<Artist>, r
private fun setupView(view: View, artist: Artist) {
view.apply {
artist_frame?.isSelected = selectedKeys.contains(artist.hashCode())
artist_title.text = if (textToHighlight.isEmpty()) artist.title else artist.title.highlightTextPart(textToHighlight, adjustedPrimaryColor)
artist_title.text = if (textToHighlight.isEmpty()) artist.title else artist.title.highlightTextPart(textToHighlight, properPrimaryColor)
artist_title.setTextColor(textColor)
val albums = resources.getQuantityString(R.plurals.albums_plural, artist.albumCnt, artist.albumCnt)

View file

@ -74,7 +74,7 @@ class FoldersAdapter(
private fun setupView(view: View, folder: Folder) {
view.apply {
folder_frame?.isSelected = selectedKeys.contains(folder.hashCode())
folder_title.text = if (textToHighlight.isEmpty()) folder.title else folder.title.highlightTextPart(textToHighlight, adjustedPrimaryColor)
folder_title.text = if (textToHighlight.isEmpty()) folder.title else folder.title.highlightTextPart(textToHighlight, properPrimaryColor)
folder_title.setTextColor(textColor)
val tracks = resources.getQuantityString(R.plurals.tracks_plural, folder.trackCount, folder.trackCount)

View file

@ -152,7 +152,7 @@ class PlaylistsAdapter(
private fun setupView(view: View, playlist: Playlist) {
view.apply {
playlist_frame?.isSelected = selectedKeys.contains(playlist.id)
playlist_title.text = if (textToHighlight.isEmpty()) playlist.title else playlist.title.highlightTextPart(textToHighlight, adjustedPrimaryColor)
playlist_title.text = if (textToHighlight.isEmpty()) playlist.title else playlist.title.highlightTextPart(textToHighlight, properPrimaryColor)
playlist_title.setTextColor(textColor)
val tracks = resources.getQuantityString(R.plurals.tracks_plural, playlist.trackCount, playlist.trackCount)

View file

@ -13,10 +13,7 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
import com.simplemobiletools.commons.extensions.getFormattedDuration
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.interfaces.ItemMoveCallback
import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract
import com.simplemobiletools.commons.interfaces.StartReorderDragListener
@ -142,7 +139,7 @@ class QueueAdapter(activity: SimpleActivity, val items: ArrayList<Track>, recycl
track_queue_title.text = track.title
arrayOf(track_queue_title, track_queue_duration).forEach {
val color = if (track == MusicService.mCurrTrack) context.getAdjustedPrimaryColor() else textColor
val color = if (track == MusicService.mCurrTrack) context.getProperPrimaryColor() else textColor
it.setTextColor(color)
}

View file

@ -174,7 +174,7 @@ class TracksAdapter(
private fun setupView(view: View, track: Track) {
view.apply {
track_frame?.isSelected = selectedKeys.contains(track.hashCode())
track_title.text = if (textToHighlight.isEmpty()) track.title else track.title.highlightTextPart(textToHighlight, adjustedPrimaryColor)
track_title.text = if (textToHighlight.isEmpty()) track.title else track.title.highlightTextPart(textToHighlight, properPrimaryColor)
arrayOf(track_id, track_title, track_duration).forEach {
it.setTextColor(textColor)

View file

@ -3,7 +3,7 @@ package com.simplemobiletools.musicplayer.adapters
import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.activities.SimpleActivity
import com.simplemobiletools.musicplayer.extensions.config
@ -20,7 +20,7 @@ class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {
(view as MyViewPagerFragment).apply {
setupFragment(activity)
setupColors(activity.config.textColor, activity.getAdjustedPrimaryColor())
setupColors(activity.config.textColor, activity.getProperPrimaryColor())
}
return view

View file

@ -67,13 +67,13 @@ class MyWidgetProvider : AppWidgetProvider() {
private fun setupIntent(context: Context, views: RemoteViews, action: String, id: Int) {
val intent = Intent(context, MyWidgetProvider::class.java)
intent.action = action
val pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0)
val pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
views.setOnClickPendingIntent(id, pendingIntent)
}
private fun setupAppOpenIntent(context: Context, views: RemoteViews, id: Int) {
val intent = context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
views.setOnClickPendingIntent(id, pendingIntent)
}

View file

@ -14,7 +14,10 @@ import android.media.MediaMetadataRetriever
import android.media.MediaPlayer
import android.media.audiofx.Equalizer
import android.net.Uri
import android.os.*
import android.os.CountDownTimer
import android.os.Handler
import android.os.Looper
import android.os.PowerManager
import android.provider.MediaStore
import android.provider.MediaStore.Audio
import android.support.v4.media.MediaMetadataCompat
@ -42,7 +45,6 @@ import com.simplemobiletools.musicplayer.receivers.NotificationDismissedReceiver
import org.greenrobot.eventbus.EventBus
import java.io.File
import java.io.IOException
import java.util.*
class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener, OnAudioFocusChangeListener {
companion object {
@ -501,13 +503,13 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
private fun getContentIntent(): PendingIntent {
val contentIntent = Intent(this, MainActivity::class.java)
return PendingIntent.getActivity(this, 0, contentIntent, 0)
return PendingIntent.getActivity(this, 0, contentIntent, PendingIntent.FLAG_IMMUTABLE)
}
private fun getIntent(action: String): PendingIntent {
val intent = Intent(this, ControlActionsListener::class.java)
intent.action = action
return PendingIntent.getBroadcast(applicationContext, 0, intent, 0)
return PendingIntent.getBroadcast(applicationContext, 0, intent, PendingIntent.FLAG_IMMUTABLE)
}
// on Android 8+ the service is launched with startForegroundService(), so startForeground must be called within a few secs

View file

@ -9,7 +9,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip