mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-05-03 09:01:33 +03:00
Remove a bunch of now unused prefs
This commit is contained in:
parent
46fb7664c3
commit
1a69507e34
@ -71,11 +71,6 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<receiver android:name=".receiver.MediaButtonIntentReceiver">
|
||||
<intent-filter android:priority="2147483647">
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receiver.UltrasonicIntentReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="org.moire.ultrasonic.CMD_TOGGLEPAUSE"/>
|
||||
@ -88,14 +83,6 @@
|
||||
<action android:name="org.moire.ultrasonic.CMD_PROCESS_KEYCODE"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receiver.BluetoothIntentReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
|
||||
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/>
|
||||
<action android:name="android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED"/>
|
||||
<action android:name="android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name=".provider.UltrasonicAppWidgetProvider4X1"
|
||||
android:label="Ultrasonic (4x1)">
|
||||
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
This file is part of Subsonic.
|
||||
|
||||
Subsonic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Subsonic is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2010 (C) Sindre Mehus
|
||||
*/
|
||||
package org.moire.ultrasonic.receiver;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.moire.ultrasonic.util.Constants;
|
||||
import org.moire.ultrasonic.util.Settings;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Resume or pause playback on Bluetooth A2DP connect/disconnect.
|
||||
*
|
||||
* @author Sindre Mehus
|
||||
*/
|
||||
@SuppressLint("MissingPermission")
|
||||
public class BluetoothIntentReceiver extends BroadcastReceiver
|
||||
{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, -1);
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
String action = intent.getAction();
|
||||
String name = device != null ? device.getName() : "Unknown";
|
||||
String address = device != null ? device.getAddress() : "Unknown";
|
||||
|
||||
Timber.d("A2DP State: %d; Action: %s; Device: %s; Address: %s", state, action, name, address);
|
||||
|
||||
boolean actionBluetoothDeviceConnected = false;
|
||||
boolean actionBluetoothDeviceDisconnected = false;
|
||||
boolean actionA2dpConnected = false;
|
||||
boolean actionA2dpDisconnected = false;
|
||||
|
||||
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action))
|
||||
{
|
||||
actionBluetoothDeviceConnected = true;
|
||||
}
|
||||
else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action) || BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED.equals(action))
|
||||
{
|
||||
actionBluetoothDeviceDisconnected = true;
|
||||
}
|
||||
|
||||
if (state == android.bluetooth.BluetoothA2dp.STATE_CONNECTED) actionA2dpConnected = true;
|
||||
else if (state == android.bluetooth.BluetoothA2dp.STATE_DISCONNECTED) actionA2dpDisconnected = true;
|
||||
|
||||
boolean resume = false;
|
||||
boolean pause = false;
|
||||
|
||||
switch (Settings.getResumeOnBluetoothDevice())
|
||||
{
|
||||
case Constants.PREFERENCE_VALUE_ALL: resume = actionA2dpConnected || actionBluetoothDeviceConnected;
|
||||
break;
|
||||
case Constants.PREFERENCE_VALUE_A2DP: resume = actionA2dpConnected;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (Settings.getPauseOnBluetoothDevice())
|
||||
{
|
||||
case Constants.PREFERENCE_VALUE_ALL: pause = actionA2dpDisconnected || actionBluetoothDeviceDisconnected;
|
||||
break;
|
||||
case Constants.PREFERENCE_VALUE_A2DP: pause = actionA2dpDisconnected;
|
||||
break;
|
||||
}
|
||||
|
||||
if (resume)
|
||||
{
|
||||
Timber.i("Connected to Bluetooth device %s address %s, resuming playback.", name, address);
|
||||
context.sendBroadcast(new Intent(Constants.CMD_RESUME_OR_PLAY).setPackage(context.getPackageName()));
|
||||
}
|
||||
|
||||
if (pause)
|
||||
{
|
||||
Timber.i("Disconnected from Bluetooth device %s address %s, requesting pause.", name, address);
|
||||
context.sendBroadcast(new Intent(Constants.CMD_PAUSE).setPackage(context.getPackageName()));
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ import android.os.Bundle
|
||||
import android.provider.DocumentsContract
|
||||
import android.provider.SearchRecentSuggestions
|
||||
import android.view.View
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.preference.CheckBoxPreference
|
||||
import androidx.preference.EditTextPreference
|
||||
@ -83,8 +82,6 @@ class SettingsFragment :
|
||||
private var sharingDefaultDescription: EditTextPreference? = null
|
||||
private var sharingDefaultGreeting: EditTextPreference? = null
|
||||
private var sharingDefaultExpiration: TimeSpanPreference? = null
|
||||
private var resumeOnBluetoothDevice: Preference? = null
|
||||
private var pauseOnBluetoothDevice: Preference? = null
|
||||
private var debugLogToFile: CheckBoxPreference? = null
|
||||
private var customCacheLocation: CheckBoxPreference? = null
|
||||
|
||||
@ -124,9 +121,6 @@ class SettingsFragment :
|
||||
sharingDefaultGreeting = findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_GREETING)
|
||||
sharingDefaultExpiration =
|
||||
findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_EXPIRATION)
|
||||
resumeOnBluetoothDevice =
|
||||
findPreference(Constants.PREFERENCES_KEY_RESUME_ON_BLUETOOTH_DEVICE)
|
||||
pauseOnBluetoothDevice = findPreference(Constants.PREFERENCES_KEY_PAUSE_ON_BLUETOOTH_DEVICE)
|
||||
debugLogToFile = findPreference(Constants.PREFERENCES_KEY_DEBUG_LOG_TO_FILE)
|
||||
showArtistPicture = findPreference(Constants.PREFERENCES_KEY_SHOW_ARTIST_PICTURE)
|
||||
customCacheLocation = findPreference(Constants.PREFERENCES_KEY_CUSTOM_CACHE_LOCATION)
|
||||
@ -134,7 +128,6 @@ class SettingsFragment :
|
||||
sharingDefaultGreeting!!.text = shareGreeting
|
||||
setupClearSearchPreference()
|
||||
setupCacheLocationPreference()
|
||||
setupBluetoothDevicePreferences()
|
||||
|
||||
// After API26 foreground services must be used for music playback, and they must have a notification
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
@ -286,72 +279,6 @@ class SettingsFragment :
|
||||
startActivityForResult(intent, SELECT_CACHE_ACTIVITY)
|
||||
}
|
||||
|
||||
private fun setupBluetoothDevicePreferences() {
|
||||
val resumeSetting = Settings.resumeOnBluetoothDevice
|
||||
val pauseSetting = Settings.pauseOnBluetoothDevice
|
||||
resumeOnBluetoothDevice!!.summary = bluetoothDevicePreferenceToString(resumeSetting)
|
||||
pauseOnBluetoothDevice!!.summary = bluetoothDevicePreferenceToString(pauseSetting)
|
||||
resumeOnBluetoothDevice!!.onPreferenceClickListener =
|
||||
Preference.OnPreferenceClickListener {
|
||||
showBluetoothDevicePreferenceDialog(
|
||||
R.string.settings_playback_resume_on_bluetooth_device,
|
||||
Settings.resumeOnBluetoothDevice
|
||||
) { choice: Int ->
|
||||
val editor = resumeOnBluetoothDevice!!.sharedPreferences.edit()
|
||||
editor.putInt(Constants.PREFERENCES_KEY_RESUME_ON_BLUETOOTH_DEVICE, choice)
|
||||
editor.apply()
|
||||
resumeOnBluetoothDevice!!.summary = bluetoothDevicePreferenceToString(choice)
|
||||
}
|
||||
true
|
||||
}
|
||||
pauseOnBluetoothDevice!!.onPreferenceClickListener =
|
||||
Preference.OnPreferenceClickListener {
|
||||
showBluetoothDevicePreferenceDialog(
|
||||
R.string.settings_playback_pause_on_bluetooth_device,
|
||||
Settings.pauseOnBluetoothDevice
|
||||
) { choice: Int ->
|
||||
Settings.pauseOnBluetoothDevice = choice
|
||||
pauseOnBluetoothDevice!!.summary = bluetoothDevicePreferenceToString(choice)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun showBluetoothDevicePreferenceDialog(
|
||||
@StringRes title: Int,
|
||||
defaultChoice: Int,
|
||||
onChosen: (Int) -> Unit
|
||||
) {
|
||||
val choice = intArrayOf(defaultChoice)
|
||||
AlertDialog.Builder(activity).setTitle(title)
|
||||
.setSingleChoiceItems(
|
||||
R.array.bluetoothDeviceSettingNames, defaultChoice
|
||||
) { _: DialogInterface?, i: Int -> choice[0] = i }
|
||||
.setNegativeButton(R.string.common_cancel) { dialogInterface: DialogInterface, _: Int ->
|
||||
dialogInterface.cancel()
|
||||
}
|
||||
.setPositiveButton(R.string.common_ok) { dialogInterface: DialogInterface, _: Int ->
|
||||
onChosen(choice[0])
|
||||
dialogInterface.dismiss()
|
||||
}
|
||||
.create().show()
|
||||
}
|
||||
|
||||
private fun bluetoothDevicePreferenceToString(preferenceValue: Int): String {
|
||||
return when (preferenceValue) {
|
||||
Constants.PREFERENCE_VALUE_ALL -> {
|
||||
getString(R.string.settings_playback_bluetooth_all)
|
||||
}
|
||||
Constants.PREFERENCE_VALUE_A2DP -> {
|
||||
getString(R.string.settings_playback_bluetooth_a2dp)
|
||||
}
|
||||
Constants.PREFERENCE_VALUE_DISABLED -> {
|
||||
getString(R.string.settings_playback_bluetooth_disabled)
|
||||
}
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupClearSearchPreference() {
|
||||
val clearSearchPreference =
|
||||
findPreference<Preference>(Constants.PREFERENCES_KEY_CLEAR_SEARCH_HISTORY)
|
||||
|
@ -180,12 +180,6 @@ class MediaPlayerController(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Playback has ended...
|
||||
if (mediaItem == null && Settings.shouldClearPlaylist) {
|
||||
clear(true)
|
||||
jukeboxMediaPlayer.updatePlaylist()
|
||||
}
|
||||
}
|
||||
|
||||
private fun publishPlaybackState() {
|
||||
|
@ -95,13 +95,10 @@ object Constants {
|
||||
const val PREFERENCES_KEY_TEMP_LOSS = "tempLoss"
|
||||
const val PREFERENCES_KEY_CHAT_REFRESH_INTERVAL = "chatRefreshInterval"
|
||||
const val PREFERENCES_KEY_DIRECTORY_CACHE_TIME = "directoryCacheTime"
|
||||
const val PREFERENCES_KEY_CLEAR_PLAYLIST = "clearPlaylist"
|
||||
const val PREFERENCES_KEY_CLEAR_BOOKMARK = "clearBookmark"
|
||||
const val PREFERENCES_KEY_DISC_SORT = "discAndTrackSort"
|
||||
const val PREFERENCES_KEY_SEND_BLUETOOTH_NOTIFICATIONS = "sendBluetoothNotifications"
|
||||
const val PREFERENCES_KEY_SEND_BLUETOOTH_ALBUM_ART = "sendBluetoothAlbumArt"
|
||||
const val PREFERENCES_KEY_DISABLE_SEND_NOW_PLAYING_LIST = "disableNowPlayingListSending"
|
||||
const val PREFERENCES_KEY_VIEW_REFRESH = "viewRefresh"
|
||||
const val PREFERENCES_KEY_ASK_FOR_SHARE_DETAILS = "sharingAlwaysAskForDetails"
|
||||
const val PREFERENCES_KEY_DEFAULT_SHARE_DESCRIPTION = "sharingDefaultDescription"
|
||||
const val PREFERENCES_KEY_DEFAULT_SHARE_GREETING = "sharingDefaultGreeting"
|
||||
@ -110,9 +107,6 @@ object Constants {
|
||||
const val PREFERENCES_KEY_USE_FIVE_STAR_RATING = "use_five_star_rating"
|
||||
const val PREFERENCES_KEY_CATEGORY_NOTIFICATIONS = "notificationsCategory"
|
||||
const val PREFERENCES_KEY_FIRST_RUN_EXECUTED = "firstRunExecuted"
|
||||
const val PREFERENCES_KEY_RESUME_ON_BLUETOOTH_DEVICE = "resumeOnBluetoothDevice"
|
||||
const val PREFERENCES_KEY_PAUSE_ON_BLUETOOTH_DEVICE = "pauseOnBluetoothDevice"
|
||||
const val PREFERENCES_KEY_SINGLE_BUTTON_PLAY_PAUSE = "singleButtonPlayPause"
|
||||
const val PREFERENCES_KEY_DEBUG_LOG_TO_FILE = "debugLogToFile"
|
||||
const val PREFERENCES_KEY_OVERRIDE_LANGUAGE = "overrideLanguage"
|
||||
const val PREFERENCE_VALUE_ALL = 0
|
||||
|
@ -124,10 +124,6 @@ object Settings {
|
||||
var defaultArtists
|
||||
by StringIntSetting(Constants.PREFERENCES_KEY_DEFAULT_ARTISTS, "3")
|
||||
|
||||
@JvmStatic
|
||||
var bufferLength
|
||||
by StringIntSetting(Constants.PREFERENCES_KEY_BUFFER_LENGTH, "5")
|
||||
|
||||
@JvmStatic
|
||||
var incrementTime
|
||||
by StringIntSetting(Constants.PREFERENCES_KEY_INCREMENT_TIME, "5")
|
||||
@ -154,9 +150,6 @@ object Settings {
|
||||
var shouldUseId3Tags
|
||||
by BooleanSetting(Constants.PREFERENCES_KEY_ID3_TAGS, false)
|
||||
|
||||
@JvmStatic
|
||||
var tempLoss by StringIntSetting(Constants.PREFERENCES_KEY_TEMP_LOSS, "1")
|
||||
|
||||
var activeServer by IntSetting(Constants.PREFERENCES_KEY_SERVER_INSTANCE, -1)
|
||||
|
||||
var serverScaling by BooleanSetting(Constants.PREFERENCES_KEY_SERVER_SCALING, false)
|
||||
@ -184,37 +177,18 @@ object Settings {
|
||||
"300"
|
||||
)
|
||||
|
||||
var shouldClearPlaylist
|
||||
by BooleanSetting(Constants.PREFERENCES_KEY_CLEAR_PLAYLIST, false)
|
||||
|
||||
var shouldSortByDisc
|
||||
by BooleanSetting(Constants.PREFERENCES_KEY_DISC_SORT, false)
|
||||
|
||||
var shouldClearBookmark
|
||||
by BooleanSetting(Constants.PREFERENCES_KEY_CLEAR_BOOKMARK, false)
|
||||
|
||||
var singleButtonPlayPause
|
||||
by BooleanSetting(
|
||||
Constants.PREFERENCES_KEY_SINGLE_BUTTON_PLAY_PAUSE,
|
||||
false
|
||||
)
|
||||
|
||||
// Inverted for readability
|
||||
var shouldSendBluetoothNotifications by BooleanSetting(
|
||||
Constants.PREFERENCES_KEY_SEND_BLUETOOTH_NOTIFICATIONS,
|
||||
true
|
||||
)
|
||||
|
||||
var shouldSendBluetoothAlbumArt
|
||||
by BooleanSetting(Constants.PREFERENCES_KEY_SEND_BLUETOOTH_ALBUM_ART, true)
|
||||
|
||||
var shouldDisableNowPlayingListSending
|
||||
by BooleanSetting(Constants.PREFERENCES_KEY_DISABLE_SEND_NOW_PLAYING_LIST, false)
|
||||
|
||||
@JvmStatic
|
||||
var viewRefreshInterval
|
||||
by StringIntSetting(Constants.PREFERENCES_KEY_VIEW_REFRESH, "1000")
|
||||
|
||||
var shouldAskForShareDetails
|
||||
by BooleanSetting(Constants.PREFERENCES_KEY_ASK_FOR_SHARE_DETAILS, true)
|
||||
|
||||
@ -257,18 +231,6 @@ object Settings {
|
||||
return 0
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
var resumeOnBluetoothDevice by IntSetting(
|
||||
Constants.PREFERENCES_KEY_RESUME_ON_BLUETOOTH_DEVICE,
|
||||
Constants.PREFERENCE_VALUE_DISABLED
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
var pauseOnBluetoothDevice by IntSetting(
|
||||
Constants.PREFERENCES_KEY_PAUSE_ON_BLUETOOTH_DEVICE,
|
||||
Constants.PREFERENCE_VALUE_A2DP
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
var debugLogToFile by BooleanSetting(Constants.PREFERENCES_KEY_DEBUG_LOG_TO_FILE, false)
|
||||
|
||||
|
@ -77,12 +77,6 @@
|
||||
a:summary="@string/settings.download_transition_summary"
|
||||
a:title="@string/settings.download_transition"
|
||||
app:iconSpaceReserved="false"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="clearPlaylist"
|
||||
a:summary="@string/settings.clear_playlist_summary"
|
||||
a:title="@string/settings.clear_playlist"
|
||||
app:iconSpaceReserved="false"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="clearBookmark"
|
||||
@ -96,26 +90,6 @@
|
||||
a:key="incrementTime"
|
||||
a:title="@string/settings.increment_time"
|
||||
app:iconSpaceReserved="false"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="@string/settings.playback.resume_play_on_headphones_plug"
|
||||
a:title="@string/settings.playback.resume_play_on_headphones_plug.title"
|
||||
a:summary="@string/settings.playback.resume_play_on_headphones_plug.summary"
|
||||
app:iconSpaceReserved="false"/>
|
||||
<Preference
|
||||
a:key="resumeOnBluetoothDevice"
|
||||
a:title="@string/settings.playback.resume_on_bluetooth_device"
|
||||
app:iconSpaceReserved="false"/>
|
||||
<Preference
|
||||
a:key="pauseOnBluetoothDevice"
|
||||
a:title="@string/settings.playback.pause_on_bluetooth_device"
|
||||
app:iconSpaceReserved="false"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="singleButtonPlayPause"
|
||||
a:summary="@string/settings.playback.single_button_bluetooth_device_summary"
|
||||
a:title="@string/settings.playback.single_button_bluetooth_device"
|
||||
app:iconSpaceReserved="false"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="use_five_star_rating"
|
||||
|
Loading…
x
Reference in New Issue
Block a user