File indexing completed on 2024-12-22 04:41:39

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Albert Vaca Cintora <albertvaka@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 package org.kde.kdeconnect.Plugins.FindRemoteDevicePlugin;
0008 
0009 import android.app.Activity;
0010 
0011 import androidx.annotation.NonNull;
0012 
0013 import org.apache.commons.lang3.ArrayUtils;
0014 import org.kde.kdeconnect.NetworkPacket;
0015 import org.kde.kdeconnect.Plugins.FindMyPhonePlugin.FindMyPhonePlugin;
0016 import org.kde.kdeconnect.Plugins.Plugin;
0017 import org.kde.kdeconnect.Plugins.PluginFactory;
0018 import org.kde.kdeconnect_tp.R;
0019 
0020 @PluginFactory.LoadablePlugin
0021 public class FindRemoteDevicePlugin extends Plugin {
0022 
0023     @Override
0024     public @NonNull String getDisplayName() {
0025         return context.getResources().getString(R.string.pref_plugin_findremotedevice);
0026     }
0027 
0028     @Override
0029     public @NonNull String getDescription() {
0030         return context.getResources().getString(R.string.pref_plugin_findremotedevice_desc);
0031     }
0032 
0033     @Override
0034     public boolean onPacketReceived(@NonNull NetworkPacket np) {
0035         return true;
0036     }
0037 
0038     @Override
0039     public @NonNull String getActionName() {
0040         return context.getString(R.string.ring);
0041     }
0042 
0043     @Override
0044     public void startMainActivity(Activity activity) {
0045         if (device != null) {
0046             device.sendPacket(new NetworkPacket(FindMyPhonePlugin.PACKET_TYPE_FINDMYPHONE_REQUEST));
0047         }
0048     }
0049 
0050     @Override
0051     public boolean displayInContextMenu() {
0052         return true;
0053     }
0054 
0055     @Override
0056     public @NonNull String[] getSupportedPacketTypes() {
0057         return ArrayUtils.EMPTY_STRING_ARRAY;
0058     }
0059 
0060     @Override
0061     public @NonNull String[] getOutgoingPacketTypes() {
0062         return new String[]{FindMyPhonePlugin.PACKET_TYPE_FINDMYPHONE_REQUEST};
0063     }
0064 }