2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 22:25:08 +00:00

Revert "Add support to deal with album arts sent by mpris plugin."

This was very poorly implemented and can't stay as it is right now:
 - Every second or so the art image was being loaded from disk, scaled,
   base64 encoded and sent over the freakin network!
 - The Android interface didn't take into account small screens, and
   adding the image would cut stuff out of the screen.
 - Didn't manage "edge cases" like playing a song without cover after one
   with cover (previous image was still being shown) or changing players.

This reverts commit 24c404400f.

# Conflicts:
#	src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java
#	src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
This commit is contained in:
Albert Vaca
2016-12-08 23:47:17 +01:00
parent 66794002f7
commit d52be109ee
3 changed files with 1 additions and 27 deletions

View File

@@ -20,11 +20,6 @@
android:id="@+id/no_players" android:id="@+id/no_players"
android:layout_gravity="center_horizontal" /> android:layout_gravity="center_horizontal" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/artImageView" />
<Spinner <Spinner
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@@ -21,7 +21,6 @@
package org.kde.kdeconnect.Plugins.MprisPlugin; package org.kde.kdeconnect.Plugins.MprisPlugin;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@@ -34,7 +33,6 @@ import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
@@ -95,12 +93,6 @@ public class MprisActivity extends ActionBarActivity {
TextView nowPlaying = (TextView) findViewById(R.id.now_playing_textview); TextView nowPlaying = (TextView) findViewById(R.id.now_playing_textview);
if (!nowPlaying.getText().toString().equals(song)) { if (!nowPlaying.getText().toString().equals(song)) {
nowPlaying.setText(song); nowPlaying.setText(song);
Bitmap currentArt = mpris.getCurrentArt();
ImageView artView = (ImageView) findViewById(R.id.artImageView);
if (currentArt != null) {
artView.setImageBitmap(currentArt);
}
} }
//Hacks for Spotify because it reports incorrect info about what it supports //Hacks for Spotify because it reports incorrect info about what it supports

View File

@@ -22,13 +22,10 @@ package org.kde.kdeconnect.Plugins.MprisPlugin;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Base64;
import android.util.Log; import android.util.Log;
import org.kde.kdeconnect.NetworkPackage; import org.kde.kdeconnect.NetworkPackage;
@@ -47,7 +44,6 @@ public class MprisPlugin extends Plugin {
private String player = ""; private String player = "";
private boolean playing = false; private boolean playing = false;
private String currentSong = ""; private String currentSong = "";
private Bitmap currentArt;
private int volume = 50; private int volume = 50;
private long length = -1; private long length = -1;
private long lastPosition; private long lastPosition;
@@ -130,8 +126,7 @@ public class MprisPlugin extends Plugin {
@Override @Override
public boolean onPackageReceived(NetworkPackage np) { public boolean onPackageReceived(NetworkPackage np) {
if (np.has("nowPlaying") || np.has("volume") || np.has("isPlaying") || np.has("length") || if (np.has("nowPlaying") || np.has("volume") || np.has("isPlaying") || np.has("length") || np.has("pos")) {
np.has("pos") || np.has("artImage")) {
if (np.getString("player").equals(player)) { if (np.getString("player").equals(player)) {
currentSong = np.getString("nowPlaying", currentSong); currentSong = np.getString("nowPlaying", currentSong);
volume = np.getInt("volume", volume); volume = np.getInt("volume", volume);
@@ -140,11 +135,6 @@ public class MprisPlugin extends Plugin {
lastPosition = np.getLong("pos", lastPosition); lastPosition = np.getLong("pos", lastPosition);
lastPositionTime = System.currentTimeMillis(); lastPositionTime = System.currentTimeMillis();
} }
if (np.has("artImage")) {
String base64Image = np.getString("artImage");
byte[] decodedBytes = Base64.decode(base64Image, 0);
currentArt = BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
}
playing = np.getBoolean("isPlaying", playing); playing = np.getBoolean("isPlaying", playing);
playAllowed = np.getBoolean("canPlay", playAllowed); playAllowed = np.getBoolean("canPlay", playAllowed);
pauseAllowed = np.getBoolean("canPause", pauseAllowed); pauseAllowed = np.getBoolean("canPause", pauseAllowed);
@@ -228,7 +218,6 @@ public class MprisPlugin extends Plugin {
if (player == null || player.equals(this.player)) return; if (player == null || player.equals(this.player)) return;
this.player = player; this.player = player;
currentSong = ""; currentSong = "";
currentArt = null;
volume = 50; volume = 50;
playing = false; playing = false;
playAllowed = true; playAllowed = true;
@@ -256,8 +245,6 @@ public class MprisPlugin extends Plugin {
return currentSong; return currentSong;
} }
public Bitmap getCurrentArt() { return currentArt; }
public String getPlayer() { public String getPlayer() {
return player; return player;
} }