diff --git a/res/values/strings.xml b/res/values/strings.xml index 23f82b72..3052a140 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -251,5 +251,8 @@ Device is not paired There is no such device This device does not have the Run Command Plugin enabled + Find remote device + Ring your remote device + Ring diff --git a/src/org/kde/kdeconnect/Plugins/FindRemoteDevicePlugin/FindRemoteDevicePlugin.java b/src/org/kde/kdeconnect/Plugins/FindRemoteDevicePlugin/FindRemoteDevicePlugin.java new file mode 100644 index 00000000..56e53a7a --- /dev/null +++ b/src/org/kde/kdeconnect/Plugins/FindRemoteDevicePlugin/FindRemoteDevicePlugin.java @@ -0,0 +1,80 @@ +/* + * Copyright 2014 Albert Vaca Cintora + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.kde.kdeconnect.Plugins.FindRemoteDevicePlugin; + +import android.app.Activity; + +import org.kde.kdeconnect.NetworkPacket; +import org.kde.kdeconnect.Plugins.FindMyPhonePlugin.FindMyPhonePlugin; +import org.kde.kdeconnect.Plugins.Plugin; +import org.kde.kdeconnect_tp.R; + + +public class FindRemoteDevicePlugin extends Plugin { + + @Override + public String getDisplayName() { + return context.getResources().getString(R.string.pref_plugin_findremotedevice); + } + + @Override + public String getDescription() { + return context.getResources().getString(R.string.pref_plugin_findremotedevice_desc); + } + + @Override + public boolean onPacketReceived(NetworkPacket np) { + return true; + } + + @Override + public String getActionName() { + return context.getString(R.string.ring); + } + + @Override + public void startMainActivity(Activity activity) { + if (device != null) { + device.sendPacket(new NetworkPacket(FindMyPhonePlugin.PACKET_TYPE_FINDMYPHONE_REQUEST)); + } + } + + @Override + public boolean hasMainActivity() { + return true; + } + + @Override + public boolean displayInContextMenu() { + return true; + } + + @Override + public String[] getSupportedPacketTypes() { + return new String[]{}; + } + + @Override + public String[] getOutgoingPacketTypes() { + return new String[]{FindMyPhonePlugin.PACKET_TYPE_FINDMYPHONE_REQUEST}; + } + +} diff --git a/src/org/kde/kdeconnect/Plugins/PluginFactory.java b/src/org/kde/kdeconnect/Plugins/PluginFactory.java index 27baaf73..42ff6846 100644 --- a/src/org/kde/kdeconnect/Plugins/PluginFactory.java +++ b/src/org/kde/kdeconnect/Plugins/PluginFactory.java @@ -29,6 +29,7 @@ import org.kde.kdeconnect.Plugins.BatteryPlugin.BatteryPlugin; import org.kde.kdeconnect.Plugins.ClibpoardPlugin.ClipboardPlugin; import org.kde.kdeconnect.Plugins.ContactsPlugin.ContactsPlugin; import org.kde.kdeconnect.Plugins.FindMyPhonePlugin.FindMyPhonePlugin; +import org.kde.kdeconnect.Plugins.FindRemoteDevicePlugin.FindRemoteDevicePlugin; import org.kde.kdeconnect.Plugins.MousePadPlugin.MousePadPlugin; import org.kde.kdeconnect.Plugins.MprisPlugin.MprisPlugin; import org.kde.kdeconnect.Plugins.MprisReceiverPlugin.MprisReceiverPlugin; @@ -132,6 +133,7 @@ public class PluginFactory { PluginFactory.registerPlugin(ContactsPlugin.class); PluginFactory.registerPlugin(RemoteKeyboardPlugin.class); //PluginFactory.registerPlugin(MprisReceiverPlugin.class); + PluginFactory.registerPlugin(FindRemoteDevicePlugin.class); } public static PluginInfo getPluginInfo(Context context, String pluginKey) {