2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Use StringUtils.contains().

This commit is contained in:
Isira Seneviratne
2020-07-09 15:17:58 +05:30
committed by Nicolas Fella
parent 84ca679d84
commit e74743c684
3 changed files with 7 additions and 11 deletions

View File

@@ -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.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -257,17 +258,10 @@ public class SMSHelper {
null,
null)
) {
if (availableColumnsCursor != null) {
return true; // if we got the cursor, the query shouldn't fail
}
return false;
return availableColumnsCursor != null; // if we got the cursor, the query shouldn't fail
} catch (SQLiteException | IllegalArgumentException e) {
// With uri content://mms-sms/conversations this query throws an exception if sub_id is not supported
String errMessage = e.getMessage();
if (errMessage != null && errMessage.contains(Telephony.Sms.SUBSCRIPTION_ID)) {
return false;
}
return true;
return !StringUtils.contains(e.getMessage(), Telephony.Sms.SUBSCRIPTION_ID);
}
}

View File

@@ -34,6 +34,7 @@ import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import org.apache.commons.lang3.StringUtils;
import org.kde.kdeconnect.Helpers.AppsHelper;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.NotificationsPlugin.NotificationReceiver;
@@ -260,7 +261,7 @@ public class MprisReceiverPlugin extends Plugin {
private boolean hasPermission() {
String notificationListenerList = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
return (notificationListenerList != null && notificationListenerList.contains(context.getPackageName()));
return StringUtils.contains(notificationListenerList, context.getPackageName());
}
}

View File

@@ -51,6 +51,7 @@ import androidx.fragment.app.DialogFragment;
import org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.kde.kdeconnect.Helpers.AppsHelper;
import org.kde.kdeconnect.NetworkPacket;
@@ -121,7 +122,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
private boolean hasPermission() {
String notificationListenerList = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
return (notificationListenerList != null && notificationListenerList.contains(context.getPackageName()));
return StringUtils.contains(notificationListenerList, context.getPackageName());
}
@Override