From 7458adc7d699446cbf580ba39357eebe72a66b51 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 12 Jul 2020 13:37:24 +0530 Subject: [PATCH] Use ArrayUtils.EMPTY_STRING_ARRAY constant. --- src/org/kde/kdeconnect/Helpers/SMSHelper.java | 5 +++-- .../kdeconnect/Helpers/SecurityHelpers/SslHelper.java | 3 ++- .../Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java | 3 ++- .../FindRemoteDevicePlugin/FindRemoteDevicePlugin.java | 4 ++-- .../kdeconnect/Plugins/MprisPlugin/MprisActivity.java | 3 ++- src/org/kde/kdeconnect/Plugins/Plugin.java | 5 +++-- .../Plugins/PresenterPlugin/PresenterPlugin.java | 10 ++++------ .../kde/kdeconnect/Plugins/SMSPlugin/SmsMmsUtils.java | 3 ++- .../Plugins/TelephonyPlugin/TelephonyPlugin.java | 3 ++- 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/org/kde/kdeconnect/Helpers/SMSHelper.java b/src/org/kde/kdeconnect/Helpers/SMSHelper.java index 6ba9c5b7..7e9ff6f0 100644 --- a/src/org/kde/kdeconnect/Helpers/SMSHelper.java +++ b/src/org/kde/kdeconnect/Helpers/SMSHelper.java @@ -40,6 +40,7 @@ import androidx.annotation.RequiresApi; import com.klinker.android.send_message.Utils; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.json.JSONArray; @@ -302,7 +303,7 @@ public class SMSHelper { try (Cursor myCursor = context.getContentResolver().query( uri, - fetchColumns.toArray(new String[]{}), + fetchColumns.toArray(ArrayUtils.EMPTY_STRING_ARRAY), selection, selectionArgs, sortOrder) @@ -401,7 +402,7 @@ public class SMSHelper { ) { try (Cursor myCursor = context.getContentResolver().query( uri, - fetchColumns.toArray(new String[]{}), + fetchColumns.toArray(ArrayUtils.EMPTY_STRING_ARRAY), selection, selectionArgs, sortOrder) diff --git a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java index de2a7b74..de1a9e66 100644 --- a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java +++ b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java @@ -29,6 +29,7 @@ import android.preference.PreferenceManager; import android.util.Base64; import android.util.Log; +import org.apache.commons.lang3.ArrayUtils; import org.kde.kdeconnect.Helpers.DeviceHelper; import org.kde.kdeconnect.Helpers.RandomHelper; import org.spongycastle.asn1.x500.RDN; @@ -241,7 +242,7 @@ public class SslHelper { supportedCiphers.add("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"); // API 20+ } supportedCiphers.add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"); // API 11+ - socket.setEnabledCipherSuites(supportedCiphers.toArray(new String[0])); + socket.setEnabledCipherSuites(supportedCiphers.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); socket.setSoTimeout(10000); diff --git a/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java b/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java index f2f93b13..cc33c7cb 100644 --- a/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java +++ b/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java @@ -38,6 +38,7 @@ import androidx.annotation.RequiresApi; import androidx.core.app.NotificationCompat; import androidx.core.content.ContextCompat; +import org.apache.commons.lang3.ArrayUtils; import org.kde.kdeconnect.Helpers.DeviceHelper; import org.kde.kdeconnect.Helpers.NotificationHelper; import org.kde.kdeconnect.MyApplication; @@ -215,7 +216,7 @@ public class FindMyPhonePlugin extends Plugin { @Override public String[] getOutgoingPacketTypes() { - return new String[0]; + return ArrayUtils.EMPTY_STRING_ARRAY; } @Override diff --git a/src/org/kde/kdeconnect/Plugins/FindRemoteDevicePlugin/FindRemoteDevicePlugin.java b/src/org/kde/kdeconnect/Plugins/FindRemoteDevicePlugin/FindRemoteDevicePlugin.java index c1f1de3f..ef2e840a 100644 --- a/src/org/kde/kdeconnect/Plugins/FindRemoteDevicePlugin/FindRemoteDevicePlugin.java +++ b/src/org/kde/kdeconnect/Plugins/FindRemoteDevicePlugin/FindRemoteDevicePlugin.java @@ -22,6 +22,7 @@ package org.kde.kdeconnect.Plugins.FindRemoteDevicePlugin; import android.app.Activity; +import org.apache.commons.lang3.ArrayUtils; import org.kde.kdeconnect.NetworkPacket; import org.kde.kdeconnect.Plugins.FindMyPhonePlugin.FindMyPhonePlugin; import org.kde.kdeconnect.Plugins.Plugin; @@ -70,12 +71,11 @@ public class FindRemoteDevicePlugin extends Plugin { @Override public String[] getSupportedPacketTypes() { - return new String[]{}; + return ArrayUtils.EMPTY_STRING_ARRAY; } @Override public String[] getOutgoingPacketTypes() { return new String[]{FindMyPhonePlugin.PACKET_TYPE_FINDMYPHONE_REQUEST}; } - } diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java index d5ed3b6d..6af9ad71 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java @@ -51,6 +51,7 @@ import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.fragment.app.FragmentManager; +import org.apache.commons.lang3.ArrayUtils; import org.kde.kdeconnect.Backends.BaseLink; import org.kde.kdeconnect.Backends.BaseLinkProvider; import org.kde.kdeconnect.BackgroundService; @@ -160,7 +161,7 @@ public class MprisActivity extends AppCompatActivity { final List playerList = mpris.getPlayerList(); final ArrayAdapter adapter = new ArrayAdapter<>(MprisActivity.this, android.R.layout.simple_spinner_item, - playerList.toArray(new String[0]) + playerList.toArray(ArrayUtils.EMPTY_STRING_ARRAY) ); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); diff --git a/src/org/kde/kdeconnect/Plugins/Plugin.java b/src/org/kde/kdeconnect/Plugins/Plugin.java index 28ddde85..d0ffe293 100644 --- a/src/org/kde/kdeconnect/Plugins/Plugin.java +++ b/src/org/kde/kdeconnect/Plugins/Plugin.java @@ -33,6 +33,7 @@ import androidx.annotation.StringRes; import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; +import org.apache.commons.lang3.ArrayUtils; import org.kde.kdeconnect.Device; import org.kde.kdeconnect.NetworkPacket; import org.kde.kdeconnect.UserInterface.AlertDialogFragment; @@ -236,11 +237,11 @@ public abstract class Plugin { public abstract String[] getOutgoingPacketTypes(); protected String[] getRequiredPermissions() { - return new String[0]; + return ArrayUtils.EMPTY_STRING_ARRAY; } protected String[] getOptionalPermissions() { - return new String[0]; + return ArrayUtils.EMPTY_STRING_ARRAY; } //Permission from Manifest.permission.* diff --git a/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java b/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java index 7ca7cfeb..27279e06 100644 --- a/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java +++ b/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java @@ -24,18 +24,16 @@ package org.kde.kdeconnect.Plugins.PresenterPlugin; import android.app.Activity; import android.content.Intent; import android.graphics.drawable.Drawable; -import android.net.Network; -import android.os.Handler; -import android.os.Message; import android.view.KeyEvent; +import androidx.core.content.ContextCompat; + +import org.apache.commons.lang3.ArrayUtils; import org.kde.kdeconnect.NetworkPacket; import org.kde.kdeconnect.Plugins.Plugin; import org.kde.kdeconnect.Plugins.PluginFactory; import org.kde.kdeconnect_tp.R; -import androidx.core.content.ContextCompat; - import static org.kde.kdeconnect.Plugins.MousePadPlugin.KeyListenerView.SpecialKeysMap; @PluginFactory.LoadablePlugin @@ -81,7 +79,7 @@ public class PresenterPlugin extends Plugin { } @Override - public String[] getSupportedPacketTypes() { return new String[0]; } + public String[] getSupportedPacketTypes() { return ArrayUtils.EMPTY_STRING_ARRAY; } @Override public String[] getOutgoingPacketTypes() { diff --git a/src/org/kde/kdeconnect/Plugins/SMSPlugin/SmsMmsUtils.java b/src/org/kde/kdeconnect/Plugins/SMSPlugin/SmsMmsUtils.java index ee60270a..50408109 100644 --- a/src/org/kde/kdeconnect/Plugins/SMSPlugin/SmsMmsUtils.java +++ b/src/org/kde/kdeconnect/Plugins/SMSPlugin/SmsMmsUtils.java @@ -32,6 +32,7 @@ import com.klinker.android.send_message.Settings; import com.klinker.android.send_message.Transaction; import com.klinker.android.send_message.Utils; +import org.apache.commons.lang3.ArrayUtils; import org.kde.kdeconnect.Helpers.SMSHelper; import org.kde.kdeconnect_tp.R; @@ -92,7 +93,7 @@ public class SmsMmsUtils { addresses.add(address.toString()); } - Message message = new Message(textMessage, addresses.toArray(new String[0])); + Message message = new Message(textMessage, addresses.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); message.setSave(true); // Sending MMS on android requires the app to be set as the default SMS app, diff --git a/src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java b/src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java index 3c80601e..145056ea 100644 --- a/src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java +++ b/src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java @@ -35,6 +35,7 @@ import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; +import org.apache.commons.lang3.ArrayUtils; import org.kde.kdeconnect.Helpers.ContactsHelper; import org.kde.kdeconnect.NetworkPacket; import org.kde.kdeconnect.Plugins.Plugin; @@ -316,7 +317,7 @@ public class TelephonyPlugin extends Plugin { Manifest.permission.READ_CALL_LOG, }; } else { - return new String[0]; + return ArrayUtils.EMPTY_STRING_ARRAY; } }