mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 21:55:10 +00:00
Add NonNull annotations to Plugin and PluginFactory
This commit is contained in:
@@ -40,12 +40,12 @@ public class BatteryPlugin extends Plugin {
|
||||
private DeviceBatteryInfo remoteBatteryInfo;
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_battery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_battery_desc);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class BatteryPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
|
||||
if (np.getBoolean("request")) {
|
||||
device.sendPacket(batteryInfo);
|
||||
@@ -139,12 +139,12 @@ public class BatteryPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_BATTERY_REQUEST, PACKET_TYPE_BATTERY};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_BATTERY_REQUEST, PACKET_TYPE_BATTERY};
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,7 @@ import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.kde.kdeconnect.Device;
|
||||
@@ -42,12 +43,12 @@ public class BigscreenPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getString(R.string.pref_plugin_bigscreen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getString(R.string.pref_plugin_bigscreen_desc);
|
||||
}
|
||||
|
||||
@@ -79,19 +80,19 @@ public class BigscreenPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() { return new String[]{PACKET_TYPE_BIGSCREEN_STT}; }
|
||||
public @NonNull String[] getSupportedPacketTypes() { return new String[]{PACKET_TYPE_BIGSCREEN_STT}; }
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MOUSEPAD_REQUEST, PACKET_TYPE_BIGSCREEN_STT};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return context.getString(R.string.pref_plugin_bigscreen);
|
||||
}
|
||||
|
||||
public String[] getOptionalPermissions() {
|
||||
public @NonNull String[] getOptionalPermissions() {
|
||||
return new String[]{Manifest.permission.RECORD_AUDIO};
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
@@ -54,17 +55,17 @@ public class ClipboardPlugin extends Plugin {
|
||||
private final static String PACKET_TYPE_CLIPBOARD_CONNECT = "kdeconnect.clipboard.connect";
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_clipboard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_clipboard_desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
String content = np.getString("content");
|
||||
switch (np.getType()) {
|
||||
case (PACKET_TYPE_CLIPBOARD):
|
||||
@@ -114,17 +115,17 @@ public class ClipboardPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_CLIPBOARD, PACKET_TYPE_CLIPBOARD_CONNECT};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_CLIPBOARD, PACKET_TYPE_CLIPBOARD_CONNECT};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return context.getString(R.string.send_clipboard);
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@ import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import org.json.JSONException;
|
||||
@@ -70,12 +71,12 @@ public class ConnectivityReportPlugin extends Plugin {
|
||||
private final HashMap<Integer, SubscriptionState> states = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_connectivity_report);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_connectivity_report_desc);
|
||||
}
|
||||
|
||||
@@ -228,7 +229,7 @@ public class ConnectivityReportPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
if (PACKET_TYPE_CONNECTIVITY_REPORT_REQUEST.equals(np.getType())) {
|
||||
Log.i("ConnectivityReport", "Requested");
|
||||
serializeSignalStrengths();
|
||||
@@ -239,17 +240,17 @@ public class ConnectivityReportPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_CONNECTIVITY_REPORT_REQUEST};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_CONNECTIVITY_REPORT};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRequiredPermissions() {
|
||||
public @NonNull String[] getRequiredPermissions() {
|
||||
return new String[]{
|
||||
Manifest.permission.READ_PHONE_STATE,
|
||||
};
|
||||
|
@@ -12,6 +12,8 @@ package org.kde.kdeconnect.Plugins.ContactsPlugin;
|
||||
import android.Manifest;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.kde.kdeconnect.Helpers.ContactsHelper;
|
||||
import org.kde.kdeconnect.Helpers.ContactsHelper.ContactNotFoundException;
|
||||
import org.kde.kdeconnect.Helpers.ContactsHelper.VCardBuilder;
|
||||
@@ -66,17 +68,17 @@ public class ContactsPlugin extends Plugin {
|
||||
private static final String PACKET_TYPE_CONTACTS_RESPONSE_VCARDS = "kdeconnect.contacts.response_vcards";
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_contacts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_contacts_desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{
|
||||
PACKET_TYPE_CONTACTS_REQUEST_ALL_UIDS_TIMESTAMPS,
|
||||
PACKET_TYPE_CONTACTS_REQUEST_VCARDS_BY_UIDS
|
||||
@@ -84,7 +86,7 @@ public class ContactsPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{
|
||||
PACKET_TYPE_CONTACTS_RESPONSE_UIDS_TIMESTAMPS,
|
||||
PACKET_TYPE_CONTACTS_RESPONSE_VCARDS
|
||||
@@ -102,7 +104,7 @@ public class ContactsPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRequiredPermissions() {
|
||||
public @NonNull String[] getRequiredPermissions() {
|
||||
return new String[]{Manifest.permission.READ_CONTACTS};
|
||||
// One day maybe we will also support WRITE_CONTACTS, but not yet
|
||||
}
|
||||
@@ -214,7 +216,7 @@ public class ContactsPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
switch (np.getType()) {
|
||||
case PACKET_TYPE_CONTACTS_REQUEST_ALL_UIDS_TIMESTAMPS:
|
||||
return this.handleRequestAllUIDsTimestamps(np);
|
||||
|
@@ -20,6 +20,7 @@ import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
@@ -47,7 +48,7 @@ public class FindMyPhonePlugin extends Plugin {
|
||||
private PowerManager powerManager;
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
switch (DeviceHelper.getDeviceType(context)) {
|
||||
case Tv:
|
||||
return context.getString(R.string.findmyphone_title_tv);
|
||||
@@ -60,7 +61,7 @@ public class FindMyPhonePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getString(R.string.findmyphone_description);
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ public class FindMyPhonePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || LifecycleHelper.isInForeground()) {
|
||||
Intent intent = new Intent(context, FindMyPhoneActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -194,12 +195,12 @@ public class FindMyPhonePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_FINDMYPHONE_REQUEST};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,8 @@ package org.kde.kdeconnect.Plugins.FindRemoteDevicePlugin;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
import org.kde.kdeconnect.Plugins.FindMyPhonePlugin.FindMyPhonePlugin;
|
||||
@@ -20,22 +22,22 @@ import org.kde.kdeconnect_tp.R;
|
||||
public class FindRemoteDevicePlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_findremotedevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_findremotedevice_desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return context.getString(R.string.ring);
|
||||
}
|
||||
|
||||
@@ -57,12 +59,12 @@ public class FindRemoteDevicePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{FindMyPhonePlugin.PACKET_TYPE_FINDMYPHONE_REQUEST};
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
@@ -29,7 +30,7 @@ public class MousePadPlugin extends Plugin {
|
||||
private boolean keyboardEnabled = true;
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
|
||||
keyboardEnabled = np.getBoolean("state", true);
|
||||
|
||||
@@ -37,12 +38,12 @@ public class MousePadPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getString(R.string.pref_plugin_mousepad);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getString(R.string.pref_plugin_mousepad_desc);
|
||||
}
|
||||
|
||||
@@ -74,17 +75,17 @@ public class MousePadPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MOUSEPAD_REQUEST};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return context.getString(R.string.open_mousepad);
|
||||
}
|
||||
|
||||
|
@@ -10,9 +10,11 @@ import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin.RemoteKeyboardPlugin;
|
||||
@@ -37,7 +39,7 @@ public class MouseReceiverPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialogFragment getPermissionExplanationDialog() {
|
||||
public @NonNull DialogFragment getPermissionExplanationDialog() {
|
||||
return new StartActivityAlertDialogFragment.Builder()
|
||||
.setTitle(R.string.mouse_receiver_plugin_description)
|
||||
.setMessage(R.string.mouse_receiver_no_permissions)
|
||||
@@ -50,7 +52,7 @@ public class MouseReceiverPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
if (!np.getType().equals(PACKET_TYPE_MOUSEPAD_REQUEST)) {
|
||||
Log.e("MouseReceiverPlugin", "Invalid packet type for MouseReceiverPlugin: " + np.getType());
|
||||
return false;
|
||||
@@ -126,22 +128,22 @@ public class MouseReceiverPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getString(R.string.mouse_receiver_plugin_name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getString(R.string.mouse_receiver_plugin_description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MOUSEPAD_REQUEST};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
return new String[0];
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
@@ -239,12 +240,12 @@ public class MprisPlugin extends Plugin {
|
||||
private final ConcurrentHashMap<String, Callback> playerListUpdated = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_mpris);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_mpris_desc);
|
||||
}
|
||||
|
||||
@@ -305,7 +306,7 @@ public class MprisPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
if (np.getBoolean("transferringAlbumArt", false)) {
|
||||
AlbumArtCache.payloadToDiskCache(np.getString("albumArtUrl"), np.getPayload());
|
||||
return true;
|
||||
@@ -405,12 +406,12 @@ public class MprisPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MPRIS};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MPRIS_REQUEST};
|
||||
}
|
||||
|
||||
@@ -493,7 +494,7 @@ public class MprisPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return context.getString(R.string.open_mpris_controls);
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@ import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.content.ContextCompat;
|
||||
@@ -86,17 +87,17 @@ public class MprisReceiverPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_mprisreceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_mprisreceiver_desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
|
||||
if (np.getBoolean("requestPlayerList")) {
|
||||
sendPlayerList();
|
||||
@@ -158,12 +159,12 @@ public class MprisReceiverPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MPRIS_REQUEST};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MPRIS};
|
||||
}
|
||||
|
||||
@@ -233,7 +234,7 @@ public class MprisReceiverPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialogFragment getPermissionExplanationDialog() {
|
||||
public @NonNull DialogFragment getPermissionExplanationDialog() {
|
||||
return new StartActivityAlertDialogFragment.Builder()
|
||||
.setTitle(R.string.pref_plugin_mpris)
|
||||
.setMessage(R.string.no_permission_mprisreceiver)
|
||||
|
@@ -82,12 +82,12 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
||||
private KeyguardManager keyguardManager;
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_notifications);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_notifications_desc);
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialogFragment getPermissionExplanationDialog() {
|
||||
public @NonNull DialogFragment getPermissionExplanationDialog() {
|
||||
return new StartActivityAlertDialogFragment.Builder()
|
||||
.setTitle(R.string.pref_plugin_notifications)
|
||||
.setMessage(R.string.no_permissions)
|
||||
@@ -568,12 +568,12 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_NOTIFICATION_REQUEST, PACKET_TYPE_NOTIFICATION_REPLY, PACKET_TYPE_NOTIFICATION_ACTION};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_NOTIFICATION};
|
||||
}
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.kde.kdeconnect.Helpers.FilesHelper;
|
||||
@@ -26,17 +27,17 @@ public class PhotoPlugin extends Plugin {
|
||||
private final static String PACKET_TYPE_PHOTO_REQUEST = "kdeconnect.photo.request";
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.take_picture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.plugin_photo_desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
Intent intent = new Intent(context, PhotoActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra("deviceId", device.getDeviceId());
|
||||
@@ -62,12 +63,12 @@ public class PhotoPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_PHOTO_REQUEST};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_PHOTO};
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
@@ -30,17 +31,17 @@ public class PingPlugin extends Plugin {
|
||||
private final static String PACKET_TYPE_PING = "kdeconnect.ping";
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_ping);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_ping_desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
|
||||
if (!np.getType().equals(PACKET_TYPE_PING)) {
|
||||
Log.e("PingPlugin", "Ping plugin should not receive packets other than pings!");
|
||||
@@ -86,7 +87,7 @@ public class PingPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return context.getString(R.string.send_ping);
|
||||
}
|
||||
|
||||
@@ -108,12 +109,12 @@ public class PingPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_PING};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_PING};
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.kde.kdeconnect.Device;
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
import org.kde.kdeconnect.UserInterface.AlertDialogFragment;
|
||||
@@ -44,7 +45,7 @@ public abstract class Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
public String getSharedPreferencesName() {
|
||||
public @NotNull String getSharedPreferencesName() {
|
||||
if (device == null) {
|
||||
throw new RuntimeException("You have to call setContext() before you can call getSharedPreferencesName()");
|
||||
}
|
||||
@@ -55,8 +56,7 @@ public abstract class Plugin {
|
||||
return this.getPluginKey() + "_preferences";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SharedPreferences getPreferences() {
|
||||
public @Nullable SharedPreferences getPreferences() {
|
||||
return this.preferences;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class Plugin {
|
||||
* To receive the network packet from the unpaired device, override
|
||||
* listensToUnpairedDevices to return true and this method.
|
||||
*/
|
||||
public boolean onUnpairedDevicePacketReceived(NetworkPacket np) {
|
||||
public boolean onUnpairedDevicePacketReceived(@NonNull NetworkPacket np) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ public abstract class Plugin {
|
||||
* Return the internal plugin name, that will be used as a
|
||||
* unique key to distinguish it. Use the class name as key.
|
||||
*/
|
||||
public String getPluginKey() {
|
||||
public final @NonNull String getPluginKey() {
|
||||
return getPluginKey(this.getClass());
|
||||
}
|
||||
|
||||
public static String getPluginKey(Class<? extends Plugin> p) {
|
||||
public static @NonNull String getPluginKey(Class<? extends Plugin> p) {
|
||||
return p.getSimpleName();
|
||||
}
|
||||
|
||||
@@ -92,19 +92,19 @@ public abstract class Plugin {
|
||||
* Return the human-readable plugin name. This function can
|
||||
* access this.context to provide translated text.
|
||||
*/
|
||||
public abstract String getDisplayName();
|
||||
public abstract @NonNull String getDisplayName();
|
||||
|
||||
/**
|
||||
* Return the human-readable description of this plugin. This
|
||||
* function can access this.context to provide translated text.
|
||||
*/
|
||||
public abstract String getDescription();
|
||||
public abstract @NonNull String getDescription();
|
||||
|
||||
/**
|
||||
* Return the action name displayed in the main activity, that
|
||||
* will call startMainActivity when clicked
|
||||
*/
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return getDisplayName();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public abstract class Plugin {
|
||||
* Return an icon associated to this plugin. This function can
|
||||
* access this.context to load the image from resources.
|
||||
*/
|
||||
public Drawable getIcon() {
|
||||
public @Nullable Drawable getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public abstract class Plugin {
|
||||
*
|
||||
* @return The PluginSettingsFragment used to display this plugins settings
|
||||
*/
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
public @Nullable PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
throw new RuntimeException("Plugin doesn't reimplement getSettingsFragment: " + getPluginKey());
|
||||
|
||||
}
|
||||
@@ -216,25 +216,25 @@ public abstract class Plugin {
|
||||
* when we have done something in response to the packet or false
|
||||
* otherwise, even though that value is unused as of now.
|
||||
*/
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should return the list of NetworkPacket types that this plugin can handle
|
||||
*/
|
||||
public abstract String[] getSupportedPacketTypes();
|
||||
public abstract @NonNull String[] getSupportedPacketTypes();
|
||||
|
||||
/**
|
||||
* Should return the list of NetworkPacket types that this plugin can send
|
||||
*/
|
||||
public abstract String[] getOutgoingPacketTypes();
|
||||
public abstract @NonNull String[] getOutgoingPacketTypes();
|
||||
|
||||
/**
|
||||
* Should return the list of permissions from Manifest.permission.* that, if not present,
|
||||
* mean the plugin can't be loaded.
|
||||
*/
|
||||
protected String[] getRequiredPermissions() {
|
||||
protected @NonNull String[] getRequiredPermissions() {
|
||||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ public abstract class Plugin {
|
||||
* Should return the list of permissions from Manifest.permission.* that enable additional
|
||||
* functionality in the plugin (without preventing the plugin to load).
|
||||
*/
|
||||
protected String[] getOptionalPermissions() {
|
||||
protected @NonNull String[] getOptionalPermissions() {
|
||||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
@@ -261,12 +261,12 @@ public abstract class Plugin {
|
||||
}
|
||||
|
||||
//Permission from Manifest.permission.*
|
||||
protected boolean isPermissionGranted(String permission) {
|
||||
protected boolean isPermissionGranted(@NonNull String permission) {
|
||||
int result = ContextCompat.checkSelfPermission(context, permission);
|
||||
return (result == PackageManager.PERMISSION_GRANTED);
|
||||
}
|
||||
|
||||
private boolean arePermissionsGranted(String[] permissions) {
|
||||
private boolean arePermissionsGranted(@NonNull String[] permissions) {
|
||||
for (String permission : permissions) {
|
||||
if (!isPermissionGranted(permission)) {
|
||||
return false;
|
||||
@@ -275,7 +275,7 @@ public abstract class Plugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
private PermissionsAlertDialogFragment requestPermissionDialog(final String[] permissions, @StringRes int reason) {
|
||||
private @NonNull PermissionsAlertDialogFragment requestPermissionDialog(@NonNull final String[] permissions, @StringRes int reason) {
|
||||
return new PermissionsAlertDialogFragment.Builder()
|
||||
.setTitle(getDisplayName())
|
||||
.setMessage(reason)
|
||||
@@ -291,11 +291,11 @@ public abstract class Plugin {
|
||||
* the problem (and how to fix it, if possible) to the user.
|
||||
*/
|
||||
|
||||
public DialogFragment getPermissionExplanationDialog() {
|
||||
public @NonNull DialogFragment getPermissionExplanationDialog() {
|
||||
return requestPermissionDialog(getRequiredPermissions(), getPermissionExplanation());
|
||||
}
|
||||
|
||||
public AlertDialogFragment getOptionalPermissionExplanationDialog() {
|
||||
public @NonNull AlertDialogFragment getOptionalPermissionExplanationDialog() {
|
||||
return requestPermissionDialog(getOptionalPermissions(), getOptionalPermissionExplanation());
|
||||
}
|
||||
|
||||
|
@@ -6,13 +6,15 @@
|
||||
|
||||
package org.kde.kdeconnect.Plugins;
|
||||
|
||||
import static org.apache.commons.collections4.SetUtils.emptyIfNull;
|
||||
import static org.apache.commons.collections4.SetUtils.unmodifiableSet;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.atteo.classindex.ClassIndex;
|
||||
import org.atteo.classindex.IndexAnnotated;
|
||||
import org.kde.kdeconnect.Device;
|
||||
@@ -27,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class PluginFactory {
|
||||
|
||||
public static void sortPluginList(List<String> plugins) {
|
||||
public static void sortPluginList(@NonNull List<String> plugins) {
|
||||
plugins.sort(Comparator.comparing(o -> pluginInfo.get(o).displayName));
|
||||
}
|
||||
|
||||
@@ -36,10 +38,10 @@ public class PluginFactory {
|
||||
|
||||
public static class PluginInfo {
|
||||
|
||||
PluginInfo(String displayName, String description, Drawable icon,
|
||||
PluginInfo(@NonNull String displayName, @NonNull String description, @Nullable Drawable icon,
|
||||
boolean enabledByDefault, boolean hasSettings, boolean supportsDeviceSpecificSettings,
|
||||
boolean listenToUnpaired, String[] supportedPacketTypes, String[] outgoingPacketTypes,
|
||||
Class<? extends Plugin> instantiableClass) {
|
||||
boolean listenToUnpaired, @NonNull String[] supportedPacketTypes, @NonNull String[] outgoingPacketTypes,
|
||||
@NonNull Class<? extends Plugin> instantiableClass) {
|
||||
this.displayName = displayName;
|
||||
this.description = description;
|
||||
this.icon = icon;
|
||||
@@ -47,20 +49,20 @@ public class PluginFactory {
|
||||
this.hasSettings = hasSettings;
|
||||
this.supportsDeviceSpecificSettings = supportsDeviceSpecificSettings;
|
||||
this.listenToUnpaired = listenToUnpaired;
|
||||
this.supportedPacketTypes = emptyIfNull(unmodifiableSet(supportedPacketTypes));
|
||||
this.outgoingPacketTypes = emptyIfNull(unmodifiableSet(outgoingPacketTypes));
|
||||
this.supportedPacketTypes = unmodifiableSet(supportedPacketTypes);
|
||||
this.outgoingPacketTypes = unmodifiableSet(outgoingPacketTypes);
|
||||
this.instantiableClass = instantiableClass;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
public @Nullable Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@@ -90,15 +92,15 @@ public class PluginFactory {
|
||||
return instantiableClass;
|
||||
}
|
||||
|
||||
private final String displayName;
|
||||
private final String description;
|
||||
private final Drawable icon;
|
||||
private final @NonNull String displayName;
|
||||
private final @NonNull String description;
|
||||
private final @Nullable Drawable icon;
|
||||
private final boolean enabledByDefault;
|
||||
private final boolean hasSettings;
|
||||
private final boolean supportsDeviceSpecificSettings;
|
||||
private final boolean listenToUnpaired;
|
||||
private final Set<String> supportedPacketTypes;
|
||||
private final Set<String> outgoingPacketTypes;
|
||||
private final @NonNull Set<String> supportedPacketTypes;
|
||||
private final @NonNull Set<String> outgoingPacketTypes;
|
||||
private final Class<? extends Plugin> instantiableClass;
|
||||
|
||||
}
|
||||
@@ -126,11 +128,11 @@ public class PluginFactory {
|
||||
Log.i("PluginFactory","Loaded "+pluginInfo.size()+" plugins");
|
||||
}
|
||||
|
||||
public static Set<String> getAvailablePlugins() {
|
||||
public static @NonNull Set<String> getAvailablePlugins() {
|
||||
return pluginInfo.keySet();
|
||||
}
|
||||
|
||||
public static Plugin instantiatePluginForDevice(Context context, String pluginKey, Device device) {
|
||||
public static @Nullable Plugin instantiatePluginForDevice(Context context, String pluginKey, Device device) {
|
||||
PluginInfo info = pluginInfo.get(pluginKey);
|
||||
try {
|
||||
Plugin plugin = info.getInstantiableClass().newInstance();
|
||||
@@ -142,7 +144,7 @@ public class PluginFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getIncomingCapabilities() {
|
||||
public static @NonNull Set<String> getIncomingCapabilities() {
|
||||
HashSet<String> capabilities = new HashSet<>();
|
||||
for (PluginInfo plugin : pluginInfo.values()) {
|
||||
capabilities.addAll(plugin.getSupportedPacketTypes());
|
||||
@@ -150,7 +152,7 @@ public class PluginFactory {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
public static Set<String> getOutgoingCapabilities() {
|
||||
public static @NonNull Set<String> getOutgoingCapabilities() {
|
||||
HashSet<String> capabilities = new HashSet<>();
|
||||
for (PluginInfo plugin : pluginInfo.values()) {
|
||||
capabilities.addAll(plugin.getOutgoingPacketTypes());
|
||||
@@ -158,7 +160,7 @@ public class PluginFactory {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
public static Set<String> pluginsForCapabilities(Set<String> incoming, Set<String> outgoing) {
|
||||
public static @NonNull Set<String> pluginsForCapabilities(Set<String> incoming, Set<String> outgoing) {
|
||||
HashSet<String> plugins = new HashSet<>();
|
||||
for (Map.Entry<String, PluginInfo> entry : pluginInfo.entrySet()) {
|
||||
String pluginId = entry.getKey();
|
||||
|
@@ -15,6 +15,7 @@ import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@@ -35,7 +36,7 @@ public class PresenterPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getString(R.string.pref_plugin_presenter);
|
||||
}
|
||||
|
||||
@@ -45,7 +46,7 @@ public class PresenterPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getString(R.string.pref_plugin_presenter_desc);
|
||||
}
|
||||
|
||||
@@ -72,15 +73,15 @@ public class PresenterPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() { return ArrayUtils.EMPTY_STRING_ARRAY; }
|
||||
public @NonNull String[] getSupportedPacketTypes() { return ArrayUtils.EMPTY_STRING_ARRAY; }
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MOUSEPAD_REQUEST, PACKET_TYPE_PRESENTER};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return context.getString(R.string.pref_plugin_presenter);
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
@@ -33,12 +34,12 @@ public class ReceiveNotificationsPlugin extends Plugin {
|
||||
private final static String PACKET_TYPE_NOTIFICATION_REQUEST = "kdeconnect.notification.request";
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_receive_notifications);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_receive_notifications_desc);
|
||||
}
|
||||
|
||||
@@ -113,12 +114,12 @@ public class ReceiveNotificationsPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_NOTIFICATION};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_NOTIFICATION_REQUEST};
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import android.view.inputmethod.ExtractedText;
|
||||
import android.view.inputmethod.ExtractedTextRequest;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.util.Pair;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
@@ -143,12 +144,12 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getString(R.string.pref_plugin_remotekeyboard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getString(R.string.pref_plugin_remotekeyboard_desc);
|
||||
}
|
||||
|
||||
@@ -173,12 +174,12 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MOUSEPAD_REQUEST};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_MOUSEPAD_ECHO, PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE};
|
||||
}
|
||||
|
||||
@@ -361,7 +362,7 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
|
||||
if (!np.getType().equals(PACKET_TYPE_MOUSEPAD_REQUEST)) {
|
||||
Log.e("RemoteKeyboardPlugin", "Invalid packet type for RemoteKeyboardPlugin: "+np.getType());
|
||||
@@ -423,7 +424,7 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
|
||||
}
|
||||
|
||||
@Override
|
||||
public DialogFragment getPermissionExplanationDialog() {
|
||||
public @NonNull DialogFragment getPermissionExplanationDialog() {
|
||||
return new StartActivityAlertDialogFragment.Builder()
|
||||
.setTitle(R.string.pref_plugin_remotekeyboard)
|
||||
.setMessage(R.string.no_permissions_remotekeyboard)
|
||||
|
@@ -15,6 +15,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
@@ -67,12 +68,12 @@ public class RunCommandPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_runcommand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_runcommand_desc);
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ public class RunCommandPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
|
||||
if (np.has("commandList")) {
|
||||
commandList.clear();
|
||||
@@ -150,12 +151,12 @@ public class RunCommandPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_RUNCOMMAND};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_RUNCOMMAND_REQUEST};
|
||||
}
|
||||
|
||||
@@ -184,7 +185,7 @@ public class RunCommandPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return context.getString(R.string.pref_plugin_runcommand);
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,7 @@ import android.telephony.PhoneNumberUtils;
|
||||
import android.telephony.SmsManager;
|
||||
import android.telephony.SmsMessage;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.klinker.android.logger.Log;
|
||||
@@ -374,17 +375,17 @@ public class SMSPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_telepathy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_telepathy_desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
long subID;
|
||||
|
||||
switch (np.getType()) {
|
||||
@@ -559,7 +560,7 @@ public class SMSPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{
|
||||
PACKET_TYPE_SMS_REQUEST,
|
||||
TelephonyPlugin.PACKET_TYPE_TELEPHONY_REQUEST,
|
||||
@@ -570,7 +571,7 @@ public class SMSPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{
|
||||
PACKET_TYPE_SMS_MESSAGE,
|
||||
PACKET_TYPE_SMS_ATTACHMENT_FILE
|
||||
@@ -578,7 +579,7 @@ public class SMSPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRequiredPermissions() {
|
||||
public @NonNull String[] getRequiredPermissions() {
|
||||
return new String[]{
|
||||
Manifest.permission.SEND_SMS,
|
||||
Manifest.permission.READ_SMS,
|
||||
|
@@ -49,12 +49,12 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
||||
private static final SimpleSftpServer server = new SimpleSftpServer();
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_sftp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_sftp_desc);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlertDialogFragment getPermissionExplanationDialog() {
|
||||
public @NonNull AlertDialogFragment getPermissionExplanationDialog() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
return new StartActivityAlertDialogFragment.Builder()
|
||||
.setTitle(getDisplayName())
|
||||
@@ -106,7 +106,7 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
if (np.getBoolean("startBrowsing")) {
|
||||
if (!server.isInitialized()) {
|
||||
try {
|
||||
@@ -219,12 +219,12 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_SFTP_REQUEST};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_SFTP};
|
||||
}
|
||||
|
||||
|
@@ -79,7 +79,7 @@ public class SharePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_sharereceiver);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class SharePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_sharereceiver_desc);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public class SharePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
public @NonNull String getActionName() {
|
||||
return context.getString(R.string.send_files);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class SharePlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
@WorkerThread
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
try {
|
||||
if (np.getType().equals(PACKET_TYPE_SHARE_REQUEST_UPDATE)) {
|
||||
if (receiveFileJob != null && receiveFileJob.isRunning()) {
|
||||
@@ -279,17 +279,17 @@ public class SharePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_SHARE_REQUEST, PACKET_TYPE_SHARE_REQUEST_UPDATE};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_SHARE_REQUEST};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOptionalPermissions() {
|
||||
public @NonNull String[] getOptionalPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
} else {
|
||||
|
@@ -9,6 +9,8 @@ package org.kde.kdeconnect.Plugins.SystemVolumePlugin;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@@ -40,17 +42,17 @@ public class SystemVolumePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_systemvolume);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_systemvolume_desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
|
||||
if (np.has("sinkList")) {
|
||||
sinks.clear();
|
||||
@@ -128,12 +130,12 @@ public class SystemVolumePlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_SYSTEMVOLUME};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{PACKET_TYPE_SYSTEMVOLUME_REQUEST};
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@ import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@@ -122,12 +123,12 @@ public class TelephonyPlugin extends Plugin {
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
public @NonNull String getDisplayName() {
|
||||
return context.getResources().getString(R.string.pref_plugin_telephony);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
public @NonNull String getDescription() {
|
||||
return context.getResources().getString(R.string.pref_plugin_telephony_desc);
|
||||
}
|
||||
|
||||
@@ -263,7 +264,7 @@ public class TelephonyPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketReceived(NetworkPacket np) {
|
||||
public boolean onPacketReceived(@NonNull NetworkPacket np) {
|
||||
|
||||
switch (np.getType()) {
|
||||
case PACKET_TYPE_TELEPHONY_REQUEST:
|
||||
@@ -291,7 +292,7 @@ public class TelephonyPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
public @NonNull String[] getSupportedPacketTypes() {
|
||||
return new String[]{
|
||||
PACKET_TYPE_TELEPHONY_REQUEST,
|
||||
PACKET_TYPE_TELEPHONY_REQUEST_MUTE,
|
||||
@@ -299,14 +300,14 @@ public class TelephonyPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOutgoingPacketTypes() {
|
||||
public @NonNull String[] getOutgoingPacketTypes() {
|
||||
return new String[]{
|
||||
PACKET_TYPE_TELEPHONY
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRequiredPermissions() {
|
||||
public @NonNull String[] getRequiredPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
return new String[]{
|
||||
Manifest.permission.READ_PHONE_STATE,
|
||||
@@ -318,7 +319,7 @@ public class TelephonyPlugin extends Plugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getOptionalPermissions() {
|
||||
public @NonNull String[] getOptionalPermissions() {
|
||||
return new String[]{
|
||||
Manifest.permission.READ_CONTACTS,
|
||||
};
|
||||
|
@@ -297,13 +297,13 @@ class DeviceFragment : Fragment() {
|
||||
device.pluginsWithoutPermissions,
|
||||
R.string.plugins_need_permission
|
||||
) { p: Plugin ->
|
||||
p.permissionExplanationDialog?.show(childFragmentManager, null)
|
||||
p.permissionExplanationDialog.show(childFragmentManager, null)
|
||||
}
|
||||
createPermissionsList(
|
||||
device.pluginsWithoutOptionalPermissions,
|
||||
R.string.plugins_need_optional_permission
|
||||
) { p: Plugin ->
|
||||
p.optionalPermissionExplanationDialog?.show(childFragmentManager, null)
|
||||
p.optionalPermissionExplanationDialog.show(childFragmentManager, null)
|
||||
}
|
||||
|
||||
requireDeviceBinding().permissionsList.adapter =
|
||||
|
Reference in New Issue
Block a user