aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Guy <glennguy83@gmail.com>2018-10-11 23:38:40 +1100
committerGlenn Guy <glennguy83@gmail.com>2018-10-11 23:38:40 +1100
commit73f5e04e0ddd23a8477ee0c9c4b3364817addede (patch)
tree81a2a5cb0a4b5668c20bec9c4efee3efa2b5747c
parent90f6cd02b7968bd3f10d3a4ddd6f2a32cce3ca46 (diff)
downloaddsub-73f5e04e0ddd23a8477ee0c9c4b3364817addede.tar.gz
dsub-73f5e04e0ddd23a8477ee0c9c4b3364817addede.tar.bz2
dsub-73f5e04e0ddd23a8477ee0c9c4b3364817addede.zip
Remove registerMediaButtonEventReceiver for API >= 21
Finally figured out that this was causing an extra controller to be registered with the AVRCP module. With DSub as the only media app running the log would show `V/NewAvrcpMediaPlayerList: onActiveSessionsChanged: number of controllers: 0` on entry into the app and would increase to 2 shortly after. On Android Pie this causes problems as the new AVRCP module's logic is causing the metadata to be sent through to the wrong controller. I'm not sure if you think I've gone about it in the correct way but I've removed the setting for media buttons as well for Lollipop onwards, considering that this setting has no effect anyway on >= 21.
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java9
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Util.java4
-rw-r--r--app/src/main/res/xml/settings_playback.xml3
3 files changed, 13 insertions, 3 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java
index 94c9b7fc..f7031146 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java
@@ -24,6 +24,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
@@ -109,6 +110,14 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
+ if(Build.VERSION.SDK_INT >= 21) {
+ CheckBoxPreference mediaButtons = (CheckBoxPreference) findPreference("mediaButtons");
+ if (mediaButtons != null) {
+ PreferenceCategory otherCategory = (PreferenceCategory) findPreference("otherSettings");
+ otherCategory.removePreference(mediaButtons);
+ }
+ }
+
int instance = this.getArguments().getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, -1);
if (instance != -1) {
PreferenceScreen preferenceScreen = expandServer(instance);
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java
index 5699cdf9..a02e7ded 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Util.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java
@@ -1294,11 +1294,11 @@ public final class Util {
public static void registerMediaButtonEventReceiver(Context context) {
- // Only do it if enabled in the settings.
+ // Only do it if enabled in the settings and api < 21
SharedPreferences prefs = getPreferences(context);
boolean enabled = prefs.getBoolean(Constants.PREFERENCES_KEY_MEDIA_BUTTONS, true);
- if (enabled) {
+ if (enabled && Build.VERSION.SDK_INT < 21) {
// AudioManager.registerMediaButtonEventReceiver() was introduced in Android 2.2.
// Use reflection to maintain compatibility with 1.5.
diff --git a/app/src/main/res/xml/settings_playback.xml b/app/src/main/res/xml/settings_playback.xml
index edaf3013..fb3501f0 100644
--- a/app/src/main/res/xml/settings_playback.xml
+++ b/app/src/main/res/xml/settings_playback.xml
@@ -117,7 +117,8 @@
</PreferenceCategory>
<PreferenceCategory
- android:title="@string/settings.other_title">
+ android:title="@string/settings.other_title"
+ android:key="otherSettings">
<CheckBoxPreference
android:title="@string/settings.shuffle_by_album"