2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

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
This commit is contained in:
Matthijs Tijink
2018-02-25 11:24:46 +01:00
parent abc5526252
commit f280e8f44e

View File

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