From 27141c1bd2ba0b3dcb1629dc4703952e87920e67 Mon Sep 17 00:00:00 2001 From: h4h13 Date: Thu, 20 Feb 2020 22:10:45 +0530 Subject: [PATCH] Added toggle to play on Bluetooth device --- .../retromusic/service/MusicService.java | 4 +-- .../retromusic/util/PreferenceUtil.java | 6 ++++ app/src/main/res/values/strings.xml | 31 +++++++++++++------ app/src/main/res/xml/pref_audio.xml | 7 +++++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java index 37e7062a..9218131d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java @@ -282,9 +282,9 @@ public class MusicService extends Service implements @Override public void onReceive(final Context context, final Intent intent) { String action = intent.getAction(); - Log.i(TAG, "onReceive: " + action); if (action != null) { - if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) { + if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) && + PreferenceUtil.getInstance(context).bluetoothSpeaker()) { if (VERSION.SDK_INT >= VERSION_CODES.M) { if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) { play(); diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java index c118a5a6..5a17f090 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java @@ -137,6 +137,8 @@ public final class PreferenceUtil { private static final String LAST_PAGE = "last_start_page"; + private static final String BLUETOOTH_PLAYBACK = "bluetooth_playback"; + private static final String LAST_MUSIC_CHOOSER = "last_music_chooser"; private static final String DEFAULT_START_PAGE = "default_start_page"; @@ -292,6 +294,10 @@ public final class PreferenceUtil { return mPreferences.getString(AUTO_DOWNLOAD_IMAGES_POLICY, "only_wifi"); } + public boolean bluetoothSpeaker() { + return mPreferences.getBoolean(BLUETOOTH_PLAYBACK, false); + } + public final boolean blurredAlbumArt() { return mPreferences.getBoolean(BLURRED_ALBUM_ART, false); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3b09e0dd..dc28a8a5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -176,6 +176,8 @@ Changelog maintained on the Telegram channel + Circle + Circular Classic @@ -257,6 +259,8 @@ Download from Last.fm + Drive mode + Edit Edit cover @@ -283,6 +287,8 @@ For you + Free + Full Full card @@ -359,6 +365,8 @@ Clearly White + Listeners + Listing files Loading products… @@ -510,6 +518,7 @@ Use the currently playing song album cover as the lockscreen wallpaper Lower the volume when a system sound is played or a notification is received The content of blacklisted folders is hidden from your library. + Start playing as soon as connected to bluetooth device Blur the album cover on the lockscreen. Can cause problems with third party apps and widgets Carousel effect for the album art in the now playing screen. Note that Card and Blur Card themes won\'t work Use the classic notification design @@ -544,6 +553,7 @@ Reduce volume on focus loss Auto-download artist images Blacklist + Bluetooth playback Blur album cover Choose equalizer Classic notification design @@ -577,6 +587,8 @@ Primary color The primary theme color, defaults to blue grey, for now works with dark colors + Pro + Black theme, Now playing themes, Carousel effect and more.. Profile @@ -631,6 +643,7 @@ Retro Music Equalizer + Retro Music Player Retro Music Pro File delete failed: %s @@ -665,6 +678,8 @@ Scanned %1$d of %2$d files. + Scrobbles + Search your library… Select all @@ -683,6 +698,8 @@ Share app + Share to Stories + Shuffle Simple @@ -696,6 +713,8 @@ Social + Share story + Song Song duration @@ -794,6 +813,8 @@ Virtualizer + Volume + Web search Welcome, @@ -817,14 +838,4 @@ You will be forwarded to the issue tracker website. Your account data is only used for authentication. - Circle - Volume - Listeners - Scrobbles - Share story - Share to Stories - Drive mode - Retro Music Player - Pro - Free diff --git a/app/src/main/res/xml/pref_audio.xml b/app/src/main/res/xml/pref_audio.xml index a37022f4..100ec3d6 100755 --- a/app/src/main/res/xml/pref_audio.xml +++ b/app/src/main/res/xml/pref_audio.xml @@ -39,4 +39,11 @@ android:title="@string/pref_title_toggle_toggle_shuffle" app:icon="@drawable/ic_shuffle_white_24dp" /> + + \ No newline at end of file