From 13ec8d7a3f0bf41680a2da6cf2f80ebdf2e4c6ec Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Wed, 9 Sep 2015 01:05:11 -0700 Subject: [PATCH] Fixed crash on older Androids --- src/org/kde/kdeconnect/Device.java | 5 +++-- src/org/kde/kdeconnect/Helpers/ObjectsHelper.java | 7 +++++++ src/org/kde/kdeconnect/UserInterface/PluginPreference.java | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 src/org/kde/kdeconnect/Helpers/ObjectsHelper.java diff --git a/src/org/kde/kdeconnect/Device.java b/src/org/kde/kdeconnect/Device.java index 5fb1bc87..19c3a234 100644 --- a/src/org/kde/kdeconnect/Device.java +++ b/src/org/kde/kdeconnect/Device.java @@ -37,6 +37,7 @@ import android.util.Base64; import android.util.Log; import org.kde.kdeconnect.Backends.BaseLink; +import org.kde.kdeconnect.Helpers.ObjectsHelper; import org.kde.kdeconnect.UserInterface.MaterialActivity; import org.kde.kdeconnect.Plugins.Plugin; import org.kde.kdeconnect.Plugins.PluginFactory; @@ -556,8 +557,8 @@ public class Device implements BaseLink.PackageReceiver { } else if (NetworkPackage.PACKAGE_TYPE_CAPABILITIES.equals(np.getType())) { ArrayList newIncomingCapabilities = np.getStringList("SupportedIncomingInterfaces"); ArrayList newOutgoingCapabilities = np.getStringList("SupportedOutgoingInterfaces"); - if (!Objects.equals(newIncomingCapabilities, incomingCapabilities) || - !Objects.equals(newOutgoingCapabilities, outgoingCapabilities)) { + if (!ObjectsHelper.equals(newIncomingCapabilities, incomingCapabilities) || + !ObjectsHelper.equals(newOutgoingCapabilities, outgoingCapabilities)) { incomingCapabilities = newIncomingCapabilities; outgoingCapabilities = newOutgoingCapabilities; reloadPluginsFromSettings(); diff --git a/src/org/kde/kdeconnect/Helpers/ObjectsHelper.java b/src/org/kde/kdeconnect/Helpers/ObjectsHelper.java new file mode 100644 index 00000000..efe6f4e7 --- /dev/null +++ b/src/org/kde/kdeconnect/Helpers/ObjectsHelper.java @@ -0,0 +1,7 @@ +package org.kde.kdeconnect.Helpers; + +public class ObjectsHelper { + public static boolean equals(Object a, Object b) { + return (a == null) ? (b == null) : a.equals(b); + } +} diff --git a/src/org/kde/kdeconnect/UserInterface/PluginPreference.java b/src/org/kde/kdeconnect/UserInterface/PluginPreference.java index 6469187c..6d5a0bd5 100644 --- a/src/org/kde/kdeconnect/UserInterface/PluginPreference.java +++ b/src/org/kde/kdeconnect/UserInterface/PluginPreference.java @@ -69,7 +69,7 @@ public class PluginPreference extends CheckBoxPreference { @Override public void onClick(View v) { boolean newState = !device.isPluginEnabled(pluginKey); - setChecked(newState); + setChecked(newState); //It actually works on API<14 button.setEnabled(newState); device.setPluginEnabled(pluginKey, newState); }