2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-09-05 08:35:10 +00:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Albert Vaca Cintora
1e58559584 Release 1.12.9 2019-06-15 13:40:16 +02:00
Albert Vaca
503eaa7ca8 Remove overly-complicated code that isn't working well
For some users, it was giving false positives or even crashing.

Detecting this across all Androids without an actual API doesn't seem
practical.
2019-06-15 13:27:18 +02:00
Albert Vaca
46cd99ba85 Upgrade gradle plugin for AS 3.4.1 2019-06-15 13:22:56 +02:00
Albert Vaca
a7d6b9a805 Fix crash if icon can't be found 2019-06-15 13:22:36 +02:00
Matthijs Tijink
f688aad3e1 Close the MPRIS media notification when the player disappears
The code now checks if the player still exists.
2019-06-14 23:19:51 +02:00
6 changed files with 37 additions and 30 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.kde.kdeconnect_tp"
android:versionCode="11280"
android:versionName="1.12.8">
android:versionCode="11290"
android:versionName="1.12.9">
<supports-screens
android:anyDensity="true"

View File

@@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:3.4.1'
}
}

View File

@@ -1,17 +1,14 @@
package org.kde.kdeconnect.Helpers;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.util.Log;
import java.io.FileReader;
import java.io.LineNumberReader;
public class NetworkHelper {
public static boolean isOnMobileNetwork(Context context) {
return false;
/*
if (context == null) {
return false;
}
@@ -52,6 +49,8 @@ public class NetworkHelper {
Log.e("isOnMobileNetwork", "Something went wrong, but this is non-critical.", e);
}
return false;
*/
}
}

View File

@@ -191,46 +191,44 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
}
private Pair<Device, MprisPlugin.MprisPlayer> findPlayer(BackgroundService service) {
//First try the previously displayed player (if still playing)
//First try the previously displayed player (if still playing) or the previous displayed device (otherwise)
if (notificationDevice != null && mprisDevices.contains(notificationDevice)) {
Device device = service.getDevice(notificationDevice);
if (device != null && device.isPluginEnabled("MprisPlugin")) {
if (shouldShowPlayer(notificationPlayer) && notificationPlayer.isPlaying()) {
return new Pair<>(device, notificationPlayer);
}
// Try a different player for the same device
MprisPlugin.MprisPlayer player = getPlayerFromDevice(device);
if (player != null) {
return new Pair<>(device, player);
}
MprisPlugin.MprisPlayer player;
if (notificationPlayer.isPlaying()) {
player = getPlayerFromDevice(device, notificationPlayer);
} else {
player = getPlayerFromDevice(device, null);
}
if (player != null) {
return new Pair<>(device, player);
}
}
// Try a different player from another device
for (Device otherDevice : service.getDevices().values()) {
MprisPlugin.MprisPlayer player = getPlayerFromDevice(otherDevice);
MprisPlugin.MprisPlayer player = getPlayerFromDevice(otherDevice, null);
if (player != null) {
return new Pair<>(otherDevice, player);
}
}
//So no player is playing. Try the previously displayed player again
// This will succeed if it's paused:
// that allows pausing and subsequently resuming via the notification
if (notificationDevice != null && mprisDevices.contains(notificationDevice)) {
Device device = service.getDevice(notificationDevice);
if (device != null && device.isPluginEnabled("MprisPlugin")) {
if (shouldShowPlayer(notificationPlayer)) {
return new Pair<>(device, notificationPlayer);
}
MprisPlugin.MprisPlayer player = getPlayerFromDevice(device, notificationPlayer);
if (player != null) {
return new Pair<>(device, player);
}
}
return new Pair<>(null, null);
}
private MprisPlugin.MprisPlayer getPlayerFromDevice(Device device) {
private MprisPlugin.MprisPlayer getPlayerFromDevice(Device device, MprisPlugin.MprisPlayer preferredPlayer) {
if (!mprisDevices.contains(device.getDeviceId()))
return null;
@@ -240,6 +238,12 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh
return null;
}
//First try the preferred player, if supplied
if (plugin.hasPlayer(preferredPlayer) && shouldShowPlayer(preferredPlayer)) {
return preferredPlayer;
}
//Otherwise, accept any playing player
MprisPlugin.MprisPlayer player = plugin.getPlayingPlayer();
if (shouldShowPlayer(player)) {
return player;

View File

@@ -422,6 +422,10 @@ public class MprisPlugin extends Plugin {
return null;
}
boolean hasPlayer(MprisPlayer player) {
return players.containsValue(player);
}
private void requestPlayerList() {
NetworkPacket np = new NetworkPacket(PACKET_TYPE_MPRIS_REQUEST);
np.set("requestPlayerList", true);

View File

@@ -304,10 +304,10 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
PackageManager pm = context.getPackageManager();
Resources foreignResources = pm.getResourcesForApplication(statusBarNotification.getPackageName());
Drawable foreignIcon = foreignResources.getDrawable(notification.icon);
Drawable foreignIcon = foreignResources.getDrawable(notification.icon); //Might throw Resources.NotFoundException
return drawableToBitmap(foreignIcon);
} catch (PackageManager.NameNotFoundException e) {
} catch (PackageManager.NameNotFoundException | Resources.NotFoundException e) {
Log.e(TAG, "Package not found", e);
}