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

Compare commits

...

9 Commits

Author SHA1 Message Date
Albert Vaca
08230950b6 Bump version to release 2019-06-17 22:21:07 +02:00
Albert Vaca
63e9e7f522 Fix crash on Android < 7.0
getOrDefault is not supported until java 8, introduced on Android 7
2019-06-17 22:12:01 +02:00
Albert Vaca Cintora
7e5df06972 1.12.9.1 2019-06-16 01:12:16 +02:00
Nicolas Fella
8dd4297a0f Check if current player is null 2019-06-15 18:41:27 +02:00
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
7 changed files with 42 additions and 31 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="11292"
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

@@ -318,7 +318,11 @@ public class SMSHelper {
@NonNull Map<String, String> messageInfo,
@NonNull int eventFlag
) {
int oldEvent = Integer.parseInt(messageInfo.getOrDefault(Message.EVENT, "0"));
int oldEvent = 0; //Default value
String oldEventString = messageInfo.get(Message.EVENT);
if (oldEventString != null) {
oldEvent = Integer.parseInt(oldEventString);
}
messageInfo.put(Message.EVENT, Integer.toString(oldEvent | eventFlag));
}

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 != null && 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);
}