mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-05 08:35:10 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
08230950b6 | ||
|
63e9e7f522 | ||
|
7e5df06972 | ||
|
8dd4297a0f | ||
|
1e58559584 | ||
|
503eaa7ca8 | ||
|
46cd99ba85 | ||
|
a7d6b9a805 | ||
|
f688aad3e1 |
@@ -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"
|
||||
|
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user