Started implementing Bluetooth connection settings
This commit is contained in:
parent
d189026c18
commit
046916221d
|
@ -64,6 +64,8 @@ public class SettingsFragment extends PreferenceFragment
|
|||
private EditTextPreference sharingDefaultGreeting;
|
||||
private TimeSpanPreference sharingDefaultExpiration;
|
||||
private PreferenceCategory serversCategory;
|
||||
private Preference resumeOnBluetoothDevice;
|
||||
private Preference pauseOnBluetoothDevice;
|
||||
|
||||
private SharedPreferences settings;
|
||||
|
||||
|
@ -110,6 +112,8 @@ public class SettingsFragment extends PreferenceFragment
|
|||
sharingDefaultGreeting = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_GREETING);
|
||||
sharingDefaultExpiration = (TimeSpanPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_EXPIRATION);
|
||||
serversCategory = (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_SERVERS_KEY);
|
||||
resumeOnBluetoothDevice = findPreference(Constants.PREFERENCES_KEY_RESUME_ON_BLUETOOTH_DEVICE);
|
||||
pauseOnBluetoothDevice = findPreference(Constants.PREFERENCES_KEY_PAUSE_ON_BLUETOOTH_DEVICE);
|
||||
|
||||
sharingDefaultGreeting.setText(Util.getShareGreeting(getActivity()));
|
||||
setupClearSearchPreference();
|
||||
|
@ -199,6 +203,18 @@ public class SettingsFragment extends PreferenceFragment
|
|||
});
|
||||
}
|
||||
|
||||
private void setupBluetoothDevicePreferences() {
|
||||
resumeOnBluetoothDevice.setSummary(settings.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION,
|
||||
FileUtil.getDefaultMusicDirectory(getActivity()).getPath()));
|
||||
|
||||
resumeOnBluetoothDevice.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupClearSearchPreference() {
|
||||
Preference clearSearchPreference = findPreference(Constants.PREFERENCES_KEY_CLEAR_SEARCH_HISTORY);
|
||||
|
||||
|
|
|
@ -19,17 +19,10 @@ public class A2dpIntentReceiver extends BroadcastReceiver
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
if (mediaPlayerControllerLazy.getValue().getCurrentPlaying() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mediaPlayerControllerLazy.getValue().getCurrentPlaying() == null) return;
|
||||
|
||||
Entry song = mediaPlayerControllerLazy.getValue().getCurrentPlaying().getSong();
|
||||
|
||||
if (song == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (song == null) return;
|
||||
|
||||
Intent avrcpIntent = new Intent(PLAYSTATUS_RESPONSE);
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.moire.ultrasonic.util.Util;
|
|||
*/
|
||||
public class BluetoothIntentReceiver extends BroadcastReceiver
|
||||
{
|
||||
|
||||
private static final String TAG = BluetoothIntentReceiver.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
|
@ -43,9 +42,10 @@ public class BluetoothIntentReceiver extends BroadcastReceiver
|
|||
int state = intent.getIntExtra("android.bluetooth.a2dp.extra.SINK_STATE", -1);
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
String action = intent.getAction();
|
||||
String name = device != null ? device.getName() : "None";
|
||||
String name = device != null ? device.getName() : "Unknown";
|
||||
String address = device != null ? device.getAddress() : "Unknown";
|
||||
|
||||
Log.d(TAG, String.format("Sink State: %d; Action: %s; Device: %s", state, action, name));
|
||||
Log.d(TAG, String.format("Sink State: %d; Action: %s; Device: %s; Address: %s", state, action, name, address));
|
||||
|
||||
boolean actionConnected = false;
|
||||
boolean actionDisconnected = false;
|
||||
|
@ -64,13 +64,13 @@ public class BluetoothIntentReceiver extends BroadcastReceiver
|
|||
|
||||
if (connected)
|
||||
{
|
||||
Log.i(TAG, "Connected to Bluetooth device, requesting media button focus.");
|
||||
Log.i(TAG, String.format("Connected to Bluetooth device %s address %s, requesting media button focus.", name, address));
|
||||
Util.registerMediaButtonEventReceiver(context, false);
|
||||
}
|
||||
|
||||
if (disconnected)
|
||||
{
|
||||
Log.i(TAG, "Disconnected from Bluetooth device, requesting pause.");
|
||||
Log.i(TAG, String.format("Disconnected from Bluetooth device %s address %s, requesting pause.", name, address));
|
||||
context.sendBroadcast(new Intent(Constants.CMD_PAUSE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,6 +131,12 @@ public final class Constants
|
|||
public static final String PREFERENCES_KEY_USE_FIVE_STAR_RATING = "use_five_star_rating";
|
||||
public static final String PREFERENCES_KEY_CATEGORY_NOTIFICATIONS = "notificationsCategory";
|
||||
public static final String PREFERENCES_KEY_FIRST_RUN_EXECUTED = "firstRunExecuted";
|
||||
public static final String PREFERENCES_KEY_RESUME_ON_BLUETOOTH_DEVICE = "resumeOnBluetoothDevice";
|
||||
public static final String PREFERENCES_KEY_PAUSE_ON_BLUETOOTH_DEVICE = "pauseOnBluetoothDevice";
|
||||
|
||||
public static final String PREFERENCE_VALUE_ALL = "all";
|
||||
public static final String PREFERENCE_VALUE_A2DP = "a2dp";
|
||||
public static final String PREFERENCE_VALUE_DISABLED = "disabled";
|
||||
|
||||
// Number of free trial days for non-licensed servers.
|
||||
public static final int FREE_TRIAL_DAYS = 30;
|
||||
|
|
|
@ -254,7 +254,7 @@
|
|||
<string name="settings.preload_5">5 songs</string>
|
||||
<string name="settings.preload_unlimited">Unlimited</string>
|
||||
<string name="settings.playback.resume_play_on_headphones_plug.title">Resume on headphones insertion</string>
|
||||
<string name="settings.playback.resume_play_on_headphones_plug.summary">App will resume paused playback on headphones insertion into device.</string>
|
||||
<string name="settings.playback.resume_play_on_headphones_plug.summary">App will resume paused playback on wired headphones insertion into device.</string>
|
||||
<string name="settings.screen_lit_summary">Keeping the screen on while downloading improves download speed.</string>
|
||||
<string name="settings.screen_lit_title">Keep Screen On</string>
|
||||
<string name="settings.scrobble_summary">Remember to set up your Last.fm user and password on the Subsonic server</string>
|
||||
|
@ -400,6 +400,11 @@
|
|||
<string name="albumArt">albumArt</string>
|
||||
<string name="common_multiple_years">Multiple Years</string>
|
||||
<string name="settings.server_address_unset" translatable="false">http://example.com</string>
|
||||
<string name="settings.playback.resume_on_bluetooth_device">Resume when a bluetooth device is connected</string>
|
||||
<string name="settings.playback.pause_on_bluetooth_device">Pause when a bluetooth device is disconnected</string>
|
||||
<string name="settings.playback.bluetooth_all">All bluetooth devices</string>
|
||||
<string name="settings.playback.bluetooth_a2dp">Only A2dp devices</string>
|
||||
<string name="settings.playback.bluetooth_disabled">Disabled</string>
|
||||
|
||||
<string name="permissions.access_error">Ultrasonic can\'t access the music file cache. Cache location was reset to the default path.</string>
|
||||
<string name="permissions.message_box_title">Warning</string>
|
||||
|
|
|
@ -106,6 +106,12 @@
|
|||
a:title="@string/settings.playback.resume_play_on_headphones_plug.title"
|
||||
a:summary="@string/settings.playback.resume_play_on_headphones_plug.summary"
|
||||
/>
|
||||
<Preference
|
||||
a:key="resumeOnBluetoothDevice"
|
||||
a:title="@string/settings.playback.resume_on_bluetooth_device"/>
|
||||
<Preference
|
||||
a:key="pauseOnBluetoothDevice"
|
||||
a:title="@string/settings.playback.pause_on_bluetooth_device"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
a:title="@string/settings.notifications_title"
|
||||
|
|
Loading…
Reference in New Issue