mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 06:05:12 +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:
@@ -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) {
|
if (targetPlayer != null) {
|
||||||
int targetIndex = adapter.getPosition(targetPlayer.getPlayer());
|
int targetIndex = adapter.getPosition(targetPlayer.getPlayer());
|
||||||
if (targetIndex >= 0) {
|
if (targetIndex >= 0) {
|
||||||
@@ -153,6 +158,11 @@ public class MprisActivity extends AppCompatActivity {
|
|||||||
targetPlayer = null;
|
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);
|
updatePlayerStatus(mpris);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user