Messaging: Language cleanup
No unnecessary boxing, enhanced for loops, redundant checks and throws, imports (removal, reordering), possible void returns Change-Id: I7a8e1b2007e3b0906e01b41785c518d02c2f3fab
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +18,6 @@ package com.android.messaging.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import androidx.core.view.accessibility.AccessibilityEventCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityRecordCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
@@ -69,10 +68,7 @@ public class AccessibilityUtil {
|
||||
event.setEnabled(view.isEnabled());
|
||||
event.setClassName(view.getClass().getName());
|
||||
event.setPackageName(context.getPackageName());
|
||||
|
||||
// JellyBean MR1 requires a source view to set the window ID.
|
||||
final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
|
||||
record.setSource(view);
|
||||
event.setSource(view);
|
||||
|
||||
// Sends the event directly through the accessibility manager. If we only supported SDK 14+
|
||||
// we could have done:
|
||||
|
||||
@@ -19,16 +19,12 @@ package com.android.messaging.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.messaging.Factory;
|
||||
import com.android.messaging.R;
|
||||
import com.android.messaging.datamodel.DataModel;
|
||||
import com.android.messaging.ui.conversation.ConversationActivity;
|
||||
import com.android.messaging.ui.conversationlist.ConversationListActivity;
|
||||
|
||||
/**
|
||||
* Utility class including logic to verify requirements to run Bugle and other activity startup
|
||||
|
||||
@@ -104,7 +104,7 @@ public class ChangeDefaultSmsAppHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private class ChangeSmsAppSettingRunnable implements Runnable {
|
||||
private static class ChangeSmsAppSettingRunnable implements Runnable {
|
||||
private final Activity mActivity;
|
||||
|
||||
public ChangeSmsAppSettingRunnable(final Activity activity) {
|
||||
|
||||
@@ -22,8 +22,6 @@ import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import com.android.messaging.datamodel.data.ParticipantData;
|
||||
|
||||
/**
|
||||
* ConnectivityUtil listens to the network service state changes.
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.messaging.util;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.ContactsContract;
|
||||
@@ -35,7 +34,6 @@ import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.ex.chips.RecipientEntry;
|
||||
import com.android.messaging.Factory;
|
||||
import com.android.messaging.datamodel.CursorQueryData;
|
||||
import com.android.messaging.datamodel.FrequentContactsCursorQueryData;
|
||||
import com.android.messaging.datamodel.data.ParticipantData;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +22,7 @@ import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Utility class to make it easy to store multiple conversation id strings in a single string
|
||||
* with delimeters.
|
||||
* with delimiters.
|
||||
*/
|
||||
public class ConversationIdSet extends HashSet<String> {
|
||||
private static final String JOIN_DELIMITER = "|";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,8 +27,8 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.ZoneId;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
@@ -18,16 +18,12 @@
|
||||
package com.android.messaging.util;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.messaging.sms.MmsUtils;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DebugUtils {
|
||||
@@ -54,14 +50,12 @@ public class DebugUtils {
|
||||
byte[] data = null;
|
||||
try {
|
||||
final File inputFile = getDebugFile(dumpFileName, false);
|
||||
if (inputFile != null) {
|
||||
final FileInputStream fis = new FileInputStream(inputFile);
|
||||
try (BufferedInputStream bis = new BufferedInputStream(fis)) {
|
||||
// dump file
|
||||
data = ByteStreams.toByteArray(bis);
|
||||
if (data == null || data.length < 1) {
|
||||
LogUtil.e(LogUtil.BUGLE_TAG, "receiveFromDumpFile: empty data");
|
||||
}
|
||||
final FileInputStream fis = new FileInputStream(inputFile);
|
||||
try (BufferedInputStream bis = new BufferedInputStream(fis)) {
|
||||
// dump file
|
||||
data = ByteStreams.toByteArray(bis);
|
||||
if (data == null || data.length < 1) {
|
||||
LogUtil.e(LogUtil.BUGLE_TAG, "receiveFromDumpFile: empty data");
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
|
||||
@@ -145,7 +145,7 @@ public final class EmailAddress {
|
||||
}
|
||||
|
||||
// check if the host contains two continuous dots.
|
||||
if (host.indexOf("..") >= 0) {
|
||||
if (host.contains("..")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public final class EmailAddress {
|
||||
}
|
||||
|
||||
// the user cannot contain two continuous dots
|
||||
if (user.indexOf("..") >= 0) {
|
||||
if (user.contains("..")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,10 @@ import android.graphics.Shader.TileMode;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.messaging.Factory;
|
||||
import com.android.messaging.datamodel.MediaScratchFileProvider;
|
||||
import com.android.messaging.datamodel.MessagingContentProvider;
|
||||
|
||||
@@ -31,6 +31,7 @@ import androidx.annotation.NonNull;
|
||||
import com.android.messaging.Factory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* This class is provides the same interface and functionality as android.media.AsyncPlayer
|
||||
@@ -257,11 +258,7 @@ public class NotificationPlayer implements OnCompletionListener {
|
||||
* @param tag a string to use for debugging
|
||||
*/
|
||||
public NotificationPlayer(final String tag) {
|
||||
if (tag != null) {
|
||||
mTag = tag;
|
||||
} else {
|
||||
mTag = "NotificationPlayer";
|
||||
}
|
||||
mTag = Objects.requireNonNullElse(tag, "NotificationPlayer");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,6 +51,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* This class abstracts away platform dependency of calling telephony related
|
||||
@@ -356,10 +358,7 @@ public class PhoneUtils {
|
||||
public List<SubscriptionInfo> getActiveSubscriptionInfoList() {
|
||||
final List<SubscriptionInfo> subscriptionInfos =
|
||||
mSubscriptionManager.getActiveSubscriptionInfoList();
|
||||
if (subscriptionInfos != null) {
|
||||
return subscriptionInfos;
|
||||
}
|
||||
return EMPTY_SUBSCRIPTION_LIST;
|
||||
return Objects.requireNonNullElse(subscriptionInfos, EMPTY_SUBSCRIPTION_LIST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1222,10 +1222,10 @@ public class ExifInterface {
|
||||
*/
|
||||
public Long getTagLongValue(int tagId, int ifdId) {
|
||||
long[] l = getTagLongValues(tagId, ifdId);
|
||||
if (l == null || l.length <= 0) {
|
||||
if (l == null || l.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return new Long(l[0]);
|
||||
return l[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1241,10 +1241,10 @@ public class ExifInterface {
|
||||
*/
|
||||
public Integer getTagIntValue(int tagId, int ifdId) {
|
||||
int[] l = getTagIntValues(tagId, ifdId);
|
||||
if (l == null || l.length <= 0) {
|
||||
if (l == null || l.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return new Integer(l[0]);
|
||||
return l[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1260,10 +1260,10 @@ public class ExifInterface {
|
||||
*/
|
||||
public Byte getTagByteValue(int tagId, int ifdId) {
|
||||
byte[] l = getTagByteValues(tagId, ifdId);
|
||||
if (l == null || l.length <= 0) {
|
||||
if (l == null || l.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return new Byte(l[0]);
|
||||
return l[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user