From f280e8f44edad6000d36f1c6d06a1622f67681cd Mon Sep 17 00:00:00 2001 From: Matthijs Tijink Date: Sun, 25 Feb 2018 11:24:46 +0100 Subject: [PATCH] Prefer selecting the playing player in the MPRIS activity Summary: Previously, the MPRIS activity just showed the first player in the list when you opened the activity. Now it shows a playing player, when possible. Test Plan: Tested with zero, one and multiple players, and with both playing and not playing players. Reviewers: #kde_connect, nicolasfella Reviewed By: #kde_connect, nicolasfella Differential Revision: https://phabricator.kde.org/D10821 --- .../kdeconnect/Plugins/MprisPlugin/MprisActivity.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java index e9036e34..9aaa4071 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java @@ -145,6 +145,11 @@ public class MprisActivity extends AppCompatActivity { } }); + if (targetPlayer == null) { + //If no player is selected, try to select a playing player + targetPlayer = mpris.getPlayingPlayer(); + } + //Try to select the specified player if (targetPlayer != null) { int targetIndex = adapter.getPosition(targetPlayer.getPlayer()); if (targetIndex >= 0) { @@ -153,6 +158,11 @@ public class MprisActivity extends AppCompatActivity { targetPlayer = null; } } + //If no player selected, select the first one (if any) + if (targetPlayer == null && !playerList.isEmpty()) { + targetPlayer = mpris.getPlayerStatus(playerList.get(0)); + spinner.setSelection(0); + } updatePlayerStatus(mpris); } });