Added toggle to play on Bluetooth device

main
h4h13 2020-02-20 22:10:45 +05:30
parent d2284f410d
commit 27141c1bd2
4 changed files with 36 additions and 12 deletions

View File

@ -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();

View File

@ -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);
}

View File

@ -176,6 +176,8 @@
<string name="changelog_summary">Changelog maintained on the Telegram channel</string>
<string name="circle">Circle</string>
<string name="circular">Circular</string>
<string name="classic">Classic</string>
@ -257,6 +259,8 @@
<string name="download_from_last_fm">Download from Last.fm</string>
<string name="drive_mode">Drive mode</string>
<string name="edit">Edit</string>
<string name="edit_cover">Edit cover</string>
@ -283,6 +287,8 @@
<string name="for_you">For you</string>
<string name="free">Free</string>
<string name="full">Full</string>
<string name="full_card">Full card</string>
@ -359,6 +365,8 @@
<string name="light_theme_name">Clearly White</string>
<string name="listeners_label">Listeners</string>
<string name="listing_files">Listing files</string>
<string name="loading_products">Loading products…</string>
@ -510,6 +518,7 @@
<string name="pref_summary_album_art_on_lockscreen">Use the currently playing song album cover as the lockscreen wallpaper</string>
<string name="pref_summary_audio_ducking">Lower the volume when a system sound is played or a notification is received</string>
<string name="pref_summary_blacklist">The content of blacklisted folders is hidden from your library.</string>
<string name="pref_summary_bluetooth_playback">Start playing as soon as connected to bluetooth device</string>
<string name="pref_summary_blurred_album_art">Blur the album cover on the lockscreen. Can cause problems with third party apps and widgets</string>
<string name="pref_summary_carousel_effect">Carousel effect for the album art in the now playing screen. Note that Card and Blur Card themes won\'t work</string>
<string name="pref_summary_classic_notification">Use the classic notification design</string>
@ -544,6 +553,7 @@
<string name="pref_title_audio_ducking">Reduce volume on focus loss</string>
<string name="pref_title_auto_download_artist_images">Auto-download artist images</string>
<string name="pref_title_blacklist">Blacklist</string>
<string name="pref_title_bluetooth_playback">Bluetooth playback</string>
<string name="pref_title_blurred_album_art">Blur album cover</string>
<string name="pref_title_choose_equalizer">Choose equalizer</string>
<string name="pref_title_classic_notification">Classic notification design</string>
@ -577,6 +587,8 @@
<string name="primary_color">Primary color</string>
<string name="primary_color_desc">The primary theme color, defaults to blue grey, for now works with dark colors</string>
<string name="pro">Pro</string>
<string name="pro_summary">Black theme, Now playing themes, Carousel effect and more..</string>
<string name="profile">Profile</string>
@ -631,6 +643,7 @@
<string name="retro_equalizer">Retro Music Equalizer</string>
<string name="retro_music_player">Retro Music Player</string>
<string name="retro_music_pro">Retro Music Pro</string>
<string name="saf_delete_failed">File delete failed: %s</string>
@ -665,6 +678,8 @@
<string name="scanned_files">Scanned %1$d of %2$d files.</string>
<string name="scrobbles_label">Scrobbles</string>
<string name="search_hint">Search your library…</string>
<string name="select_all">Select all</string>
@ -683,6 +698,8 @@
<string name="share_app">Share app</string>
<string name="share_to_stories">Share to Stories</string>
<string name="shuffle">Shuffle</string>
<string name="simple">Simple</string>
@ -696,6 +713,8 @@
<string name="social">Social</string>
<string name="social_stories">Share story</string>
<string name="song">Song</string>
<string name="song_duration">Song duration</string>
@ -794,6 +813,8 @@
<string name="virtualizer">Virtualizer</string>
<string name="volume">Volume</string>
<string name="web_search">Web search</string>
<string name="welcome">Welcome,</string>
@ -817,14 +838,4 @@
<string name="you_will_be_forwarded_to_the_issue_tracker_website">You will be forwarded to the issue tracker website.</string>
<string name="your_account_data_is_only_used_for_authentication">Your account data is only used for authentication.</string>
<string name="circle">Circle</string>
<string name="volume">Volume</string>
<string name="listeners_label">Listeners</string>
<string name="scrobbles_label">Scrobbles</string>
<string name="social_stories">Share story</string>
<string name="share_to_stories">Share to Stories</string>
<string name="drive_mode">Drive mode</string>
<string name="retro_music_player">Retro Music Player</string>
<string name="pro">Pro</string>
<string name="free">Free</string>
</resources>

View File

@ -39,4 +39,11 @@
android:title="@string/pref_title_toggle_toggle_shuffle"
app:icon="@drawable/ic_shuffle_white_24dp" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false"
android:key="bluetooth_playback"
android:layout="@layout/list_item_view_switch"
android:summary="@string/pref_summary_bluetooth_playback"
android:title="@string/pref_title_bluetooth_playback" />
</androidx.preference.PreferenceScreen>