2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 05:07:40 +00:00

Add find remote device plugin

Summary: Counterpart for D11773

Test Plan: Apply D11773, hit Ring, hear sound. Phone to phone works too

Reviewers: #kde_connect, albertvaka

Reviewed By: #kde_connect, albertvaka

Subscribers: albertvaka, kdeconnect, kossebau, #kde_connect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D12344
This commit is contained in:
Nicolas Fella 2018-07-27 07:58:07 +02:00
parent 57fc625af9
commit 2a7535053a
3 changed files with 85 additions and 0 deletions

View File

@ -251,5 +251,8 @@
<string name="runcommand_notpaired">Device is not paired</string>
<string name="runcommand_nosuchdevice">There is no such device</string>
<string name="runcommand_noruncommandplugin">This device does not have the Run Command Plugin enabled</string>
<string name="pref_plugin_findremotedevice">Find remote device</string>
<string name="pref_plugin_findremotedevice_desc">Ring your remote device</string>
<string name="ring">Ring</string>
</resources>

View File

@ -0,0 +1,80 @@
/*
* Copyright 2014 Albert Vaca Cintora <albertvaka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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};
}
}

View File

@ -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) {