2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 22:25:08 +00:00
This commit is contained in:
Albert Vaca Cintora
2022-12-28 17:31:52 +01:00
parent ea66605ef0
commit 6ab846cbbd

View File

@@ -161,6 +161,9 @@ public class BackgroundService extends Service {
} }
public Device getDevice(String id) { public Device getDevice(String id) {
if (id == null) {
return null;
}
return devices.get(id); return devices.get(id);
} }
@@ -370,21 +373,24 @@ public class BackgroundService extends Service {
} }
if (connectedDeviceIds.size() == 1) { if (connectedDeviceIds.size() == 1) {
// Adding two action buttons only when there is a single device connected. String deviceId = connectedDeviceIds.get(0);
// Setting up Send File Intent. Device device = getDevice(deviceId);
Intent sendFile = new Intent(this, SendFileActivity.class); if (device != null) {
sendFile.putExtra("deviceId", connectedDeviceIds.get(0)); // Adding two action buttons only when there is a single device connected.
PendingIntent sendPendingFile = PendingIntent.getActivity(this, 1, sendFile, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE); // Setting up Send File Intent.
notification.addAction(0, getString(R.string.send_files), sendPendingFile); Intent sendFile = new Intent(this, SendFileActivity.class);
sendFile.putExtra("deviceId", deviceId);
PendingIntent sendPendingFile = PendingIntent.getActivity(this, 1, sendFile, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
notification.addAction(0, getString(R.string.send_files), sendPendingFile);
// Checking if there are registered commands and adding the button. // Checking if there are registered commands and adding the button.
Device device = getDevice(connectedDeviceIds.get(0)); RunCommandPlugin plugin = (RunCommandPlugin) device.getPlugin("RunCommandPlugin");
RunCommandPlugin plugin = (RunCommandPlugin) device.getPlugin("RunCommandPlugin"); if (plugin != null && !plugin.getCommandList().isEmpty()) {
if (plugin != null && !plugin.getCommandList().isEmpty()) { Intent runCommand = new Intent(this, RunCommandActivity.class);
Intent runCommand = new Intent(this, RunCommandActivity.class); runCommand.putExtra("deviceId", connectedDeviceIds.get(0));
runCommand.putExtra("deviceId", connectedDeviceIds.get(0)); PendingIntent runPendingCommand = PendingIntent.getActivity(this, 2, runCommand, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
PendingIntent runPendingCommand = PendingIntent.getActivity(this, 2, runCommand, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE); notification.addAction(0, getString(R.string.pref_plugin_runcommand), runPendingCommand);
notification.addAction(0, getString(R.string.pref_plugin_runcommand), runPendingCommand); }
} }
} }
} }