diff --git a/app/build.gradle b/app/build.gradle index 76738816..1f7169d5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,14 +9,14 @@ android { defaultConfig { minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 31 renderscriptTargetApi 29//must match target sdk and build tools vectorDrawables.useSupportLibrary = true applicationId "code.name.monkey.retromusic" - versionCode 10519 - versionName '5.0.0' + "_" + getDate() + versionCode 10537 + versionName '5.2.1 ' + "_" + getDate() buildConfigField("String", "GOOGLE_PLAY_LICENSING_KEY", "\"${getProperty(getProperties('../public.properties'), 'GOOGLE_PLAY_LICENSE_KEY')}\"") } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 26baf707..806fdf4b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -35,6 +35,7 @@ tools:targetApi="m"> @@ -147,7 +148,8 @@ android:label="@string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait" - android:theme="@style/Theme.AppCompat.NoActionBar"> + android:theme="@style/Theme.AppCompat.NoActionBar" + android:exported="true"> @@ -176,13 +178,17 @@ android:resource="@xml/provider_paths" /> - + - + @@ -274,17 +280,6 @@ android:name="com.android.vending.splits.required" android:value="true" /> - - - - - = VERSION_CODES.M) { - if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) { + private int shuffleMode; + private final SongPlayCountHelper songPlayCountHelper = new SongPlayCountHelper(); + private final BroadcastReceiver bluetoothReceiver = + new BroadcastReceiver() { + @Override + public void onReceive(final Context context, final Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) + && PreferenceUtil.INSTANCE.isBluetoothSpeaker()) { + if (VERSION.SDK_INT >= VERSION_CODES.M) { + if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) { play(); + } + } else { + if (getAudioManager().isBluetoothA2dpOn()) { + play(); + } + } + } } - } else { - if (getAudioManager().isBluetoothA2dpOn()) { - play(); - } - } } - } - } - }; - private final PhoneStateListener phoneStateListener = - new PhoneStateListener() { - @Override - public void onCallStateChanged(int state, String incomingNumber) { - switch (state) { - case TelephonyManager.CALL_STATE_IDLE: - // Not in call: Play music - play(); - break; - case TelephonyManager.CALL_STATE_RINGING: - case TelephonyManager.CALL_STATE_OFFHOOK: - // A call is dialing, active or on hold - pause(); - break; - default: - } - super.onCallStateChanged(state, incomingNumber); - } - }; - private final BroadcastReceiver headsetReceiver = - new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action != null) { - if (Intent.ACTION_HEADSET_PLUG.equals(action)) { - int state = intent.getIntExtra("state", -1); - switch (state) { - case 0: - pause(); + }; + private final PhoneStateListener phoneStateListener = + new PhoneStateListener() { + @Override + public void onCallStateChanged(int state, String incomingNumber) { + switch (state) { + case TelephonyManager.CALL_STATE_IDLE: + // Not in call: Play music + play(); + break; + case TelephonyManager.CALL_STATE_RINGING: + case TelephonyManager.CALL_STATE_OFFHOOK: + // A call is dialing, active or on hold + pause(); + break; + default: + } + super.onCallStateChanged(state, incomingNumber); + } + }; + private final BroadcastReceiver headsetReceiver = + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (Intent.ACTION_HEADSET_PLUG.equals(action)) { + int state = intent.getIntExtra("state", -1); + switch (state) { + case 0: + pause(); break; case 1: play(); @@ -1123,7 +1123,7 @@ public class MusicService extends MediaBrowserServiceCompat if (playback instanceof CrossFadePlayer) { ((CrossFadePlayer) playback).sourceChangedByUser(); } - } else { + } else { trackEndedByCrossfade = false; } if (openTrackAndPrepareNextAt(position)) { @@ -1594,15 +1594,18 @@ public class MusicService extends MediaBrowserServiceCompat Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(mediaButtonReceiverComponentName); - PendingIntent mediaButtonReceiverPendingIntent = - PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0); + PendingIntent mediaButtonReceiverPendingIntent; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { + mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, PendingIntent.FLAG_MUTABLE); + } else { + mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0); + } - mediaSession = - new MediaSessionCompat( - this, - "RetroMusicPlayer", - mediaButtonReceiverComponentName, - mediaButtonReceiverPendingIntent); + mediaSession = new MediaSessionCompat( + this, + "RetroMusicPlayer", + mediaButtonReceiverComponentName, + mediaButtonReceiverPendingIntent); MediaSessionCallback mediasessionCallback = new MediaSessionCallback(getApplicationContext(), this); mediaSession.setFlags( diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt index b188f4b9..511e3659 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt +++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt @@ -69,13 +69,21 @@ class PlayingNotificationImpl : PlayingNotification(), KoinComponent { action.putExtra(MainActivity.EXPAND_PANEL, PreferenceUtil.isExpandPanel) action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP val clickIntent = - PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_IMMUTABLE) + } else { + PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT) + } val serviceName = ComponentName(service, MusicService::class.java) val intent = Intent(ACTION_QUIT) intent.component = serviceName - val deleteIntent = PendingIntent.getService(service, 0, intent, 0) - + val deleteIntent = PendingIntent.getService( + service, + 0, + intent, + PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT + ) val bigNotificationImageSize = service.resources .getDimensionPixelSize(R.dimen.notification_big_image_size) service.runOnUiThread { @@ -191,6 +199,6 @@ class PlayingNotificationImpl : PlayingNotification(), KoinComponent { val serviceName = ComponentName(service, MusicService::class.java) val intent = Intent(action) intent.component = serviceName - return PendingIntent.getService(service, 0, intent, 0) + return PendingIntent.getService(service, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) } } \ No newline at end of file diff --git a/app/src/main/res/xml/automotive_app_desc.xml b/app/src/main/res/xml/automotive_app_desc.xml deleted file mode 100644 index 0f739ff8..00000000 --- a/app/src/main/res/xml/automotive_app_desc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file