From ec42f11bc6e808fde3244208e1a03d342168627a Mon Sep 17 00:00:00 2001 From: Pavle Portic Date: Sat, 26 Jan 2019 02:39:35 +0100 Subject: [PATCH] Show current album in textview --- .../com/theedgeofrage/i3control/MainActivity.java | 6 ++++-- app/src/main/res/layout/activity_main.xml | 15 ++++++++++++++- backend/run.py | 10 ++++++---- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/theedgeofrage/i3control/MainActivity.java b/app/src/main/java/com/theedgeofrage/i3control/MainActivity.java index a0ec948..5685c72 100644 --- a/app/src/main/java/com/theedgeofrage/i3control/MainActivity.java +++ b/app/src/main/java/com/theedgeofrage/i3control/MainActivity.java @@ -81,12 +81,14 @@ public class MainActivity extends AppCompatActivity { public void onResponse(JSONObject response) { if (response.length() > 0) { try { - String current = response.getString("artist") + " - " + response.getString("title"); - TextView statusTextView = findViewById(R.id.currentlyPlayingText); + TextView statusTextView = findViewById(R.id.statusText); + TextView albumTextView = findViewById(R.id.albumText); ImageButton playButton = findViewById(R.id.playButton); ImageButton shuffleButton = findViewById(R.id.shuffleButton); + String current = response.getString("artist") + " - " + response.getString("title"); statusTextView.setText(current); + albumTextView.setText(response.getString("album")); if (response.getBoolean("playing")) { playButton.setImageResource(R.drawable.ic_pause_black_24dp); } else { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 0a96248..8b2a9ba 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -119,7 +119,7 @@ app:layout_constraintTop_toBottomOf="@+id/volUpButton" /> + + diff --git a/backend/run.py b/backend/run.py index 999b61e..172c293 100755 --- a/backend/run.py +++ b/backend/run.py @@ -60,14 +60,16 @@ def query(): status['playing'] = True elif line == 'status paused': status['playing'] = False - elif line.startswith('tag artist '): - status['artist'] = line[11:] - elif line.startswith('tag title '): - status['title'] = line[10:] elif line == 'set shuffle true': status['shuffle'] = True elif line == 'set shuffle false': status['shuffle'] = False + elif line.startswith('tag artist '): + status['artist'] = line[11:] + elif line.startswith('tag album '): + status['album'] = line[10:] + elif line.startswith('tag title '): + status['title'] = line[10:] return jsonify(status)