From b2f5e3190e2383e63c9dbbe94cbd2cd2e0992965 Mon Sep 17 00:00:00 2001 From: Michael W Date: Wed, 1 Jan 2025 13:54:07 +0100 Subject: [PATCH] Messaging: Further code improvements * Remove redundant casts * getParcelable(ArrayList|Exra) without class argument is deprecated * ViewPager.setOnPageChangeListener -> addOnPageChangeListener * RecyclerView.setOnScrollListener -> addOnScrollListener * Remove unused initializations * Remove unused code Change-Id: I21beb6c90c675a4f2cfd7e3d5ebbd18b745f5911 --- .../v7/mms/DefaultApnSettingsLoader.java | 4 +- src/android/support/v7/mms/MmsHttpClient.java | 4 +- src/android/support/v7/mms/MmsManager.java | 2 +- src/android/support/v7/mms/MmsService.java | 3 +- src/android/support/v7/mms/pdu/Base64.java | 6 +- .../support/v7/mms/pdu/GenericPdu.java | 2 +- src/android/support/v7/mms/pdu/PduBody.java | 2 +- .../support/v7/mms/pdu/PduHeaders.java | 2 +- src/android/support/v7/mms/pdu/PduParser.java | 14 +-- src/android/support/v7/mms/pdu/PduPart.java | 2 +- .../datamodel/BugleDatabaseOperations.java | 8 +- .../datamodel/MessageNotificationState.java | 4 +- .../datamodel/MessagingContentProvider.java | 2 +- .../NoConfirmationSmsSendService.java | 2 +- .../messaging/datamodel/action/Action.java | 2 +- .../datamodel/action/ActionMonitor.java | 8 +- .../datamodel/action/ActionServiceImpl.java | 11 +- .../action/BackgroundWorkerService.java | 2 +- .../datamodel/action/DownloadMmsAction.java | 2 +- .../FixupMessageStatusOnStartupAction.java | 4 +- .../action/GetOrCreateConversationAction.java | 3 +- .../action/InsertNewMessageAction.java | 2 +- .../action/ProcessDeliveryReportAction.java | 2 +- .../action/ProcessDownloadedMmsAction.java | 20 +-- .../action/ProcessPendingMessagesAction.java | 8 +- .../action/ProcessSentMessageAction.java | 11 +- .../datamodel/action/ReadDraftDataAction.java | 3 +- .../action/ReceiveSmsMessageAction.java | 3 +- .../datamodel/action/SendMessageAction.java | 6 +- .../datamodel/action/SyncCursorPair.java | 2 +- .../datamodel/action/SyncMessageBatch.java | 2 +- .../datamodel/action/SyncMessagesAction.java | 15 +-- .../action/WriteDraftMessageAction.java | 2 +- .../datamodel/data/DraftMessageData.java | 2 +- .../messaging/datamodel/data/MessageData.java | 3 +- .../datamodel/media/DecodedImageResource.java | 1 - .../datamodel/media/GifImageResource.java | 2 +- .../datamodel/media/MediaResourceManager.java | 2 +- .../datamodel/media/VCardResourceEntry.java | 2 +- .../media/VideoThumbnailRequest.java | 2 +- .../messaging/mmslib/pdu/PduComposer.java | 16 +-- .../messaging/mmslib/pdu/PduPersister.java | 11 +- .../mmslib/util/DrmConvertSession.java | 4 +- .../messaging/mmslib/util/PduCache.java | 2 +- .../receiver/SendStatusReceiver.java | 2 +- .../messaging/sms/BugleApnSettingsLoader.java | 4 +- .../messaging/sms/DatabaseMessages.java | 2 +- src/com/android/messaging/sms/MmsUtils.java | 2 +- .../messaging/ui/AttachmentPreview.java | 4 +- .../ui/AttachmentPreviewFactory.java | 16 +-- .../ui/AudioAttachmentPlayPauseButton.java | 5 +- .../messaging/ui/AudioAttachmentView.java | 10 +- .../ui/BlockedParticipantListItemView.java | 4 +- .../ui/BlockedParticipantsFragment.java | 2 +- .../messaging/ui/ClassZeroActivity.java | 3 +- .../ui/CustomHeaderPagerListViewHolder.java | 7 +- .../messaging/ui/CustomHeaderViewPager.java | 4 +- .../messaging/ui/FixedViewPagerAdapter.java | 2 +- .../android/messaging/ui/LicenseActivity.java | 3 +- .../android/messaging/ui/LineWrapLayout.java | 1 - .../android/messaging/ui/ListEmptyView.java | 5 +- .../messaging/ui/OrientedBitmapDrawable.java | 3 +- .../messaging/ui/PermissionCheckActivity.java | 4 +- .../android/messaging/ui/PersonItemView.java | 6 +- src/com/android/messaging/ui/SnackBar.java | 6 +- .../messaging/ui/VCardDetailActivity.java | 2 +- .../messaging/ui/VCardDetailFragment.java | 2 +- .../messaging/ui/VideoThumbnailView.java | 8 +- .../ApplicationSettingsActivity.java | 4 +- .../ui/appsettings/GroupMmsSettingDialog.java | 6 +- .../PerSubscriptionSettingsActivity.java | 6 +- .../ui/appsettings/SettingsActivity.java | 6 +- .../AttachmentChooserFragment.java | 2 +- .../AttachmentGridItemView.java | 4 +- .../attachmentchooser/AttachmentGridView.java | 4 +- .../AddContactsConfirmationDialog.java | 4 +- .../ui/contact/ContactListItemView.java | 14 +-- .../ui/contact/ContactPickerFragment.java | 4 +- .../ui/conversation/ComposeMessageView.java | 21 ++-- .../ui/conversation/ConversationActivity.java | 5 +- .../ui/conversation/ConversationFragment.java | 19 ++- .../ConversationMessageBubbleView.java | 2 +- .../conversation/ConversationMessageView.java | 36 +++--- .../ui/conversation/MessageDetailsDialog.java | 2 +- .../ui/conversation/SimSelectorItemView.java | 6 +- .../ui/conversation/SimSelectorView.java | 2 +- .../ConversationListFragment.java | 12 +- .../ConversationListItemView.java | 31 +++-- .../ForwardMessageActivity.java | 3 +- .../conversationlist/ShareIntentActivity.java | 5 +- .../conversationlist/ShareIntentFragment.java | 4 +- .../PeopleAndOptionsFragment.java | 6 +- .../PeopleOptionsItemView.java | 2 +- .../ui/mediapicker/AudioRecordView.java | 8 +- .../messaging/ui/mediapicker/MediaPicker.java | 6 +- .../ui/mediapicker/MediaPickerPanel.java | 4 +- .../messaging/util/AccessibilityUtil.java | 4 +- .../android/messaging/util/EmailAddress.java | 2 +- .../android/messaging/util/ImageUtils.java | 1 - .../messaging/util/NotificationPlayer.java | 27 +--- .../messaging/util/NotificationsUtil.java | 7 +- src/com/android/messaging/util/TextUtil.java | 17 +-- .../messaging/util/TintDrawableWrapper.java | 70 ----------- src/com/android/messaging/util/UriUtil.java | 29 +---- .../android/messaging/util/VersionUtil.java | 7 +- .../messaging/util/WakeLockHelper.java | 119 ------------------ .../messaging/util/exif/ExifInterface.java | 8 +- .../messaging/util/exif/ExifParser.java | 6 +- .../messaging/util/exif/ExifReader.java | 2 +- .../widget/WidgetConversationService.java | 4 +- 110 files changed, 289 insertions(+), 561 deletions(-) delete mode 100644 src/com/android/messaging/util/TintDrawableWrapper.java delete mode 100644 src/com/android/messaging/util/WakeLockHelper.java diff --git a/src/android/support/v7/mms/DefaultApnSettingsLoader.java b/src/android/support/v7/mms/DefaultApnSettingsLoader.java index d55f5fe..e92c4b8 100644 --- a/src/android/support/v7/mms/DefaultApnSettingsLoader.java +++ b/src/android/support/v7/mms/DefaultApnSettingsLoader.java @@ -290,7 +290,7 @@ class DefaultApnSettingsLoader implements ApnSettingsLoader { } else { uri = Telephony.Carriers.CONTENT_URI; } - Cursor cursor = null; + Cursor cursor; try { for (; ; ) { // Try different combinations of queries. Some would work on some platforms. @@ -448,7 +448,7 @@ class DefaultApnSettingsLoader implements ApnSettingsLoader { return addr; } final StringBuilder builder = new StringBuilder(16); - String result = null; + String result; for (int i = 0; i < 4; i++) { try { if (octets[i].length() > 3) { diff --git a/src/android/support/v7/mms/MmsHttpClient.java b/src/android/support/v7/mms/MmsHttpClient.java index c9ff941..bdf9f94 100644 --- a/src/android/support/v7/mms/MmsHttpClient.java +++ b/src/android/support/v7/mms/MmsHttpClient.java @@ -195,7 +195,7 @@ public class MmsHttpClient { final InputStream in = new BufferedInputStream(connection.getInputStream()); final ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); final byte[] buf = new byte[4096]; - int count = 0; + int count; while ((count = in.read(buf)) > 0) { byteOut.write(buf, 0, count); } @@ -438,7 +438,7 @@ public class MmsHttpClient { if (!TextUtils.isEmpty(naiSuffix)) { nai = nai + naiSuffix; } - byte[] encoded = null; + byte[] encoded; encoded = Base64.encode(nai.getBytes(StandardCharsets.UTF_8), Base64.NO_WRAP); return new String(encoded, StandardCharsets.UTF_8); } diff --git a/src/android/support/v7/mms/MmsManager.java b/src/android/support/v7/mms/MmsManager.java index d84e64b..a40c785 100644 --- a/src/android/support/v7/mms/MmsManager.java +++ b/src/android/support/v7/mms/MmsManager.java @@ -131,7 +131,7 @@ public class MmsManager { * @return a Bundle containing the overrides */ private static Bundle getConfigOverrides(final int subId) { - Bundle overrides = null; + Bundle overrides; synchronized (sConfigOverridesMap) { overrides = sConfigOverridesMap.get(subId); if (overrides == null) { diff --git a/src/android/support/v7/mms/MmsService.java b/src/android/support/v7/mms/MmsService.java index 444a347..1e63001 100644 --- a/src/android/support/v7/mms/MmsService.java +++ b/src/android/support/v7/mms/MmsService.java @@ -220,7 +220,8 @@ public class MmsService extends Service { // embedded in the intent to make sure it is indeed from the // the current life of this service. if (fromThisProcess(intent)) { - final MmsRequest request = intent.getParcelableExtra(EXTRA_REQUEST); + final MmsRequest request = intent.getParcelableExtra(EXTRA_REQUEST, + MmsRequest.class); if (request != null) { try { retainService(request, () -> { diff --git a/src/android/support/v7/mms/pdu/Base64.java b/src/android/support/v7/mms/pdu/Base64.java index 3ef3ed4..685a2c1 100644 --- a/src/android/support/v7/mms/pdu/Base64.java +++ b/src/android/support/v7/mms/pdu/Base64.java @@ -72,13 +72,13 @@ public class Base64 { } int numberQuadruple = base64Data.length / FOURBYTE; - byte[] decodedData = null; - byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0; + byte[] decodedData; + byte b1, b2, b3, b4, marker0, marker1; // Throw away anything not in base64Data int encodedIndex = 0; - int dataIndex = 0; + int dataIndex; { // this sizes the output array properly - rlw int lastData = base64Data.length; diff --git a/src/android/support/v7/mms/pdu/GenericPdu.java b/src/android/support/v7/mms/pdu/GenericPdu.java index 04fa1f4..b9ac1b4 100644 --- a/src/android/support/v7/mms/pdu/GenericPdu.java +++ b/src/android/support/v7/mms/pdu/GenericPdu.java @@ -22,7 +22,7 @@ public class GenericPdu { /** * The headers of pdu. */ - PduHeaders mPduHeaders = null; + PduHeaders mPduHeaders; /** * Constructor. diff --git a/src/android/support/v7/mms/pdu/PduBody.java b/src/android/support/v7/mms/pdu/PduBody.java index c635ef7..246fd18 100644 --- a/src/android/support/v7/mms/pdu/PduBody.java +++ b/src/android/support/v7/mms/pdu/PduBody.java @@ -21,7 +21,7 @@ package android.support.v7.mms.pdu; import java.util.Vector; public class PduBody { - private Vector mParts = null; + private Vector mParts; /** * Constructor. diff --git a/src/android/support/v7/mms/pdu/PduHeaders.java b/src/android/support/v7/mms/pdu/PduHeaders.java index 5329a4e..dff139b 100644 --- a/src/android/support/v7/mms/pdu/PduHeaders.java +++ b/src/android/support/v7/mms/pdu/PduHeaders.java @@ -323,7 +323,7 @@ public class PduHeaders { /** * The map contains the value of all headers. */ - private SparseArray mHeaderMap = null; + private SparseArray mHeaderMap; /** * Constructor of PduHeaders. diff --git a/src/android/support/v7/mms/pdu/PduParser.java b/src/android/support/v7/mms/pdu/PduParser.java index f34d0c4..1d9c590 100644 --- a/src/android/support/v7/mms/pdu/PduParser.java +++ b/src/android/support/v7/mms/pdu/PduParser.java @@ -73,7 +73,7 @@ public class PduParser { /** * The pdu data. */ - private ByteArrayInputStream mPduDataStream = null; + private ByteArrayInputStream mPduDataStream; /** * Store pdu headers @@ -550,7 +550,7 @@ public class PduParser { * Value-length * (Address-present-token Encoded-string-value | Insert-address-token) */ - EncodedStringValue from = null; + EncodedStringValue from; parseValueLength(pduDataStream); /* parse value-length */ /* Address-present-token or Insert-address-token */ @@ -1059,7 +1059,7 @@ public class PduParser { */ assert(null != pduDataStream); pduDataStream.mark(1); - EncodedStringValue returnValue = null; + EncodedStringValue returnValue; int charset = 0; int temp = pduDataStream.read(); assert(-1 != temp); @@ -1392,7 +1392,7 @@ public class PduParser { assert(length > 0); int startPos = pduDataStream.available(); - int tempPos = 0; + int tempPos; int lastLen = length; while(0 < lastLen) { int param = pduDataStream.read(); @@ -1561,7 +1561,7 @@ public class PduParser { */ assert(null != pduDataStream); - byte[] contentType = null; + byte[] contentType; pduDataStream.mark(1); int temp = pduDataStream.read(); assert(-1 != temp); @@ -1645,7 +1645,7 @@ public class PduParser { * contain the corresponding definitions. */ int startPos = pduDataStream.available(); - int tempPos = 0; + int tempPos; int lastLen = length; while(0 < lastLen) { int header = pduDataStream.read(); @@ -1700,7 +1700,7 @@ public class PduParser { int len = parseValueLength(pduDataStream); pduDataStream.mark(1); int thisStartPos = pduDataStream.available(); - int thisEndPos = 0; + int thisEndPos; int value = pduDataStream.read(); if (value == PduPart.P_DISPOSITION_FROM_DATA ) { diff --git a/src/android/support/v7/mms/pdu/PduPart.java b/src/android/support/v7/mms/pdu/PduPart.java index 476d483..c2dbcdf 100644 --- a/src/android/support/v7/mms/pdu/PduPart.java +++ b/src/android/support/v7/mms/pdu/PduPart.java @@ -106,7 +106,7 @@ public class PduPart { /** * Header of part. */ - private SparseArray mPartHeader = null; + private SparseArray mPartHeader; /** * Data uri. diff --git a/src/com/android/messaging/datamodel/BugleDatabaseOperations.java b/src/com/android/messaging/datamodel/BugleDatabaseOperations.java index 422f7d5..ca0f557 100644 --- a/src/com/android/messaging/datamodel/BugleDatabaseOperations.java +++ b/src/com/android/messaging/datamodel/BugleDatabaseOperations.java @@ -433,7 +433,7 @@ public class BugleDatabaseOperations { Assert.isNotMainThread(); dbWrapper.beginTransaction(); boolean conversationDeleted = false; - boolean conversationMessagesDeleted = false; + boolean conversationMessagesDeleted; try { // Delete existing messages if (cutoffTimestamp == Long.MAX_VALUE) { @@ -1558,7 +1558,7 @@ public class BugleDatabaseOperations { public static ParticipantData getOrCreateSelf(final DatabaseWrapper dbWrapper, final int subId) { Assert.isNotMainThread(); - ParticipantData participant = null; + ParticipantData participant; dbWrapper.beginTransaction(); try { final ParticipantData shell = ParticipantData.getSelfParticipant(subId); @@ -1583,8 +1583,8 @@ public class BugleDatabaseOperations { Assert.isNotMainThread(); Assert.isTrue(dbWrapper.getDatabase().inTransaction()); int subId = ParticipantData.OTHER_THAN_SELF_SUB_ID; - String participantId = null; - String canonicalRecipient = null; + String participantId; + String canonicalRecipient; if (participant.isSelf()) { subId = participant.getSubId(); canonicalRecipient = getCanonicalRecipientFromSubId(subId); diff --git a/src/com/android/messaging/datamodel/MessageNotificationState.java b/src/com/android/messaging/datamodel/MessageNotificationState.java index dc1602e..f217ee5 100644 --- a/src/com/android/messaging/datamodel/MessageNotificationState.java +++ b/src/com/android/messaging/datamodel/MessageNotificationState.java @@ -377,7 +377,7 @@ public abstract class MessageNotificationState extends NotificationState { @Override protected NotificationCompat.Style build(final Builder builder) { builder.setContentTitle(mTitle); - NotificationCompat.InboxStyle inboxStyle = null; + NotificationCompat.InboxStyle inboxStyle; inboxStyle = new NotificationCompat.InboxStyle(builder); final Context context = Factory.get().getApplicationContext(); @@ -507,7 +507,7 @@ public abstract class MessageNotificationState extends NotificationState { builder.setContentTitle(mTitle) .setTicker(getTicker()); - NotificationCompat.Style notifStyle = null; + NotificationCompat.Style notifStyle; final ConversationLineInfo convInfo = mConvList.mConvInfos.get(0); final List lineInfos = convInfo.mLineInfos; final int messageCount = lineInfos.size(); diff --git a/src/com/android/messaging/datamodel/MessagingContentProvider.java b/src/com/android/messaging/datamodel/MessagingContentProvider.java index c2402ac..7ca66c1 100644 --- a/src/com/android/messaging/datamodel/MessagingContentProvider.java +++ b/src/com/android/messaging/datamodel/MessagingContentProvider.java @@ -446,7 +446,7 @@ public class MessagingContentProvider extends ContentProvider { @Override public boolean onCreate() { // This is going to wind up calling into createDatabase() below. - mDatabaseHelper = (DatabaseHelper) getDatabase(); + mDatabaseHelper = getDatabase(); // We cannot initialize mDatabaseWrapper yet as the Factory may not be initialized return true; } diff --git a/src/com/android/messaging/datamodel/NoConfirmationSmsSendService.java b/src/com/android/messaging/datamodel/NoConfirmationSmsSendService.java index 1185388..718f9b4 100644 --- a/src/com/android/messaging/datamodel/NoConfirmationSmsSendService.java +++ b/src/com/android/messaging/datamodel/NoConfirmationSmsSendService.java @@ -109,7 +109,7 @@ public class NoConfirmationSmsSendService extends IntentService { if (TextUtils.isEmpty(conversationId)) { InsertNewMessageAction.insertNewMessage(subId, recipients, message, subject); } else { - MessageData messageData = null; + MessageData messageData; if (requiresMms) { if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) { LogUtil.v(TAG, "Auto-sending MMS message in conversation: " + diff --git a/src/com/android/messaging/datamodel/action/Action.java b/src/com/android/messaging/datamodel/action/Action.java index bdd9237..f771637 100644 --- a/src/com/android/messaging/datamodel/action/Action.java +++ b/src/com/android/messaging/datamodel/action/Action.java @@ -243,7 +243,7 @@ public abstract class Action implements Parcelable { * Helper method to generate a unique operation index */ protected static long getActionIdx() { - long idx = 0; + long idx; synchronized (sLock) { idx = ++sActionIdx; } diff --git a/src/com/android/messaging/datamodel/action/ActionMonitor.java b/src/com/android/messaging/datamodel/action/ActionMonitor.java index 6423679..73b44d0 100644 --- a/src/com/android/messaging/datamodel/action/ActionMonitor.java +++ b/src/com/android/messaging/datamodel/action/ActionMonitor.java @@ -196,7 +196,7 @@ public class ActionMonitor { * Return flag to indicate if action is complete */ public boolean isComplete() { - boolean complete = false; + boolean complete; synchronized (mLock) { complete = (mState == STATE_COMPLETE); } @@ -291,7 +291,7 @@ public class ActionMonitor { */ private void complete(final Action action, final int expectedOldState, final Object result, final boolean succeeded) { - ActionCompletedListener completedListener = null; + ActionCompletedListener completedListener; synchronized (mLock) { setState(action, expectedOldState, STATE_COMPLETE); completedListener = mCompletedListener; @@ -357,7 +357,7 @@ public class ActionMonitor { */ final void executed(final Action action, final int expectedOldState, final boolean hasBackgroundActions, final Object result) { - ActionExecutedListener executedListener = null; + ActionExecutedListener executedListener; synchronized (mLock) { if (hasBackgroundActions) { setState(action, expectedOldState, STATE_BACKGROUND_ACTIONS_QUEUED); @@ -432,7 +432,7 @@ public class ActionMonitor { * Find monitor associated with particular action */ private static ActionMonitor lookupActionMonitor(final String actionKey) { - ActionMonitor monitor = null; + ActionMonitor monitor; synchronized (sActionMonitors) { monitor = sActionMonitors.get(actionKey); } diff --git a/src/com/android/messaging/datamodel/action/ActionServiceImpl.java b/src/com/android/messaging/datamodel/action/ActionServiceImpl.java index 74b291d..e021033 100644 --- a/src/com/android/messaging/datamodel/action/ActionServiceImpl.java +++ b/src/com/android/messaging/datamodel/action/ActionServiceImpl.java @@ -228,11 +228,6 @@ public class ActionServiceImpl extends JobIntentService { */ @Override protected void onHandleWork(@NonNull final Intent intent) { - if (intent == null) { - // Shouldn't happen but sometimes does following another crash. - LogUtil.w(TAG, "ActionService.onHandleIntent: Called with null intent"); - return; - } final int opcode = intent.getIntExtra(EXTRA_OP_CODE, 0); Action action; @@ -240,20 +235,20 @@ public class ActionServiceImpl extends JobIntentService { actionBundle.setClassLoader(getClassLoader()); switch(opcode) { case OP_START_ACTION: { - action = (Action) actionBundle.getParcelable(BUNDLE_ACTION); + action = actionBundle.getParcelable(BUNDLE_ACTION, Action.class); executeAction(action); break; } case OP_RECEIVE_BACKGROUND_RESPONSE: { - action = (Action) actionBundle.getParcelable(BUNDLE_ACTION); + action = actionBundle.getParcelable(BUNDLE_ACTION, Action.class); final Bundle response = intent.getBundleExtra(EXTRA_WORKER_RESPONSE); processBackgroundResponse(action, response); break; } case OP_RECEIVE_BACKGROUND_FAILURE: { - action = (Action) actionBundle.getParcelable(BUNDLE_ACTION); + action = actionBundle.getParcelable(BUNDLE_ACTION, Action.class); processBackgroundFailure(action); break; } diff --git a/src/com/android/messaging/datamodel/action/BackgroundWorkerService.java b/src/com/android/messaging/datamodel/action/BackgroundWorkerService.java index 68f2946..a97521f 100644 --- a/src/com/android/messaging/datamodel/action/BackgroundWorkerService.java +++ b/src/com/android/messaging/datamodel/action/BackgroundWorkerService.java @@ -116,7 +116,7 @@ public class BackgroundWorkerService extends JobIntentService { */ private void doBackgroundWork(final Action action, final int attempt) { action.markBackgroundWorkStarting(); - Bundle response = null; + Bundle response; try { final LoggingTimer timer = new LoggingTimer( TAG, action.getClass().getSimpleName() + "#doBackgroundWork"); diff --git a/src/com/android/messaging/datamodel/action/DownloadMmsAction.java b/src/com/android/messaging/datamodel/action/DownloadMmsAction.java index c69bac9..b002b90 100644 --- a/src/com/android/messaging/datamodel/action/DownloadMmsAction.java +++ b/src/com/android/messaging/datamodel/action/DownloadMmsAction.java @@ -237,7 +237,7 @@ public class DownloadMmsAction extends Action implements Parcelable { final Context context = Factory.get().getApplicationContext(); final int subId = actionParameters.getInt(KEY_SUB_ID); final String messageId = actionParameters.getString(KEY_MESSAGE_ID); - final Uri notificationUri = actionParameters.getParcelable(KEY_NOTIFICATION_URI); + final Uri notificationUri = actionParameters.getParcelable(KEY_NOTIFICATION_URI, Uri.class); final String subPhoneNumber = actionParameters.getString(KEY_SUB_PHONE_NUMBER); final String transactionId = actionParameters.getString(KEY_TRANSACTION_ID); final String contentLocation = actionParameters.getString(KEY_CONTENT_LOCATION); diff --git a/src/com/android/messaging/datamodel/action/FixupMessageStatusOnStartupAction.java b/src/com/android/messaging/datamodel/action/FixupMessageStatusOnStartupAction.java index 722fea2..96e698c 100644 --- a/src/com/android/messaging/datamodel/action/FixupMessageStatusOnStartupAction.java +++ b/src/com/android/messaging/datamodel/action/FixupMessageStatusOnStartupAction.java @@ -49,8 +49,8 @@ public class FixupMessageStatusOnStartupAction extends Action implements Parcela // Now mark any messages in active sending or downloading state as inactive final DatabaseWrapper db = DataModel.get().getDatabase(); db.beginTransaction(); - int downloadFailedCnt = 0; - int sendFailedCnt = 0; + int downloadFailedCnt; + int sendFailedCnt; try { // For both sending and downloading messages, let's assume they failed. // For MMS sent/downloaded via platform, the sent/downloaded pending intent diff --git a/src/com/android/messaging/datamodel/action/GetOrCreateConversationAction.java b/src/com/android/messaging/datamodel/action/GetOrCreateConversationAction.java index 35e0fc3..f584f85 100644 --- a/src/com/android/messaging/datamodel/action/GetOrCreateConversationAction.java +++ b/src/com/android/messaging/datamodel/action/GetOrCreateConversationAction.java @@ -97,7 +97,8 @@ public class GetOrCreateConversationAction extends Action implements Parcelable // First find the thread id for this list of participants. final ArrayList participants = - actionParameters.getParcelableArrayList(KEY_PARTICIPANTS_LIST); + actionParameters.getParcelableArrayList(KEY_PARTICIPANTS_LIST, + ParticipantData.class); BugleDatabaseOperations.sanitizeConversationParticipants(participants); final ArrayList recipients = BugleDatabaseOperations.getRecipientsFromConversationParticipants(participants); diff --git a/src/com/android/messaging/datamodel/action/InsertNewMessageAction.java b/src/com/android/messaging/datamodel/action/InsertNewMessageAction.java index b53c212..00b9658 100644 --- a/src/com/android/messaging/datamodel/action/InsertNewMessageAction.java +++ b/src/com/android/messaging/datamodel/action/InsertNewMessageAction.java @@ -120,7 +120,7 @@ public class InsertNewMessageAction extends Action implements Parcelable { */ @Override protected Object executeAction() { - MessageData message = actionParameters.getParcelable(KEY_MESSAGE); + MessageData message = actionParameters.getParcelable(KEY_MESSAGE, MessageData.class); if (message == null) { LogUtil.i(TAG, "InsertNewMessageAction: Creating MessageData with provided data"); message = createMessage(); diff --git a/src/com/android/messaging/datamodel/action/ProcessDeliveryReportAction.java b/src/com/android/messaging/datamodel/action/ProcessDeliveryReportAction.java index 3821484..1f29010 100644 --- a/src/com/android/messaging/datamodel/action/ProcessDeliveryReportAction.java +++ b/src/com/android/messaging/datamodel/action/ProcessDeliveryReportAction.java @@ -56,7 +56,7 @@ public class ProcessDeliveryReportAction extends Action implements Parcelable { @Override protected Object executeAction() { - final Uri smsMessageUri = actionParameters.getParcelable(KEY_URI); + final Uri smsMessageUri = actionParameters.getParcelable(KEY_URI, Uri.class); final int status = actionParameters.getInt(KEY_STATUS); final DatabaseWrapper db = DataModel.get().getDatabase(); diff --git a/src/com/android/messaging/datamodel/action/ProcessDownloadedMmsAction.java b/src/com/android/messaging/datamodel/action/ProcessDownloadedMmsAction.java index 7d09e97..26c56e0 100644 --- a/src/com/android/messaging/datamodel/action/ProcessDownloadedMmsAction.java +++ b/src/com/android/messaging/datamodel/action/ProcessDownloadedMmsAction.java @@ -98,8 +98,9 @@ public class ProcessDownloadedMmsAction extends Action { // This is called when MMS lib API returns via PendingIntent public static void processMessageDownloaded(final int resultCode, final Bundle extras) { final String messageId = extras.getString(DownloadMmsAction.EXTRA_MESSAGE_ID); - final Uri contentUri = extras.getParcelable(DownloadMmsAction.EXTRA_CONTENT_URI); - final Uri notificationUri = extras.getParcelable(DownloadMmsAction.EXTRA_NOTIFICATION_URI); + final Uri contentUri = extras.getParcelable(DownloadMmsAction.EXTRA_CONTENT_URI, Uri.class); + final Uri notificationUri = extras.getParcelable(DownloadMmsAction.EXTRA_NOTIFICATION_URI, + Uri.class); final String conversationId = extras.getString(DownloadMmsAction.EXTRA_CONVERSATION_ID); final String participantId = extras.getString(DownloadMmsAction.EXTRA_PARTICIPANT_ID); Assert.notNull(messageId); @@ -245,7 +246,7 @@ public class ProcessDownloadedMmsAction extends Action { if (downloadedByPlatform) { final int resultCode = actionParameters.getInt(KEY_RESULT_CODE); if (resultCode == Activity.RESULT_OK) { - final Uri contentUri = actionParameters.getParcelable(KEY_CONTENT_URI); + final Uri contentUri = actionParameters.getParcelable(KEY_CONTENT_URI, Uri.class); final File downloadedFile = MmsFileProvider.getFile(contentUri); byte[] downloadedData = null; try { @@ -273,7 +274,7 @@ public class ProcessDownloadedMmsAction extends Action { if (retrieveConf != null) { // Insert the downloaded MMS into telephony final Uri notificationUri = actionParameters.getParcelable( - KEY_NOTIFICATION_URI); + KEY_NOTIFICATION_URI, Uri.class); final String subPhoneNumber = actionParameters.getString( KEY_SUB_PHONE_NUMBER); final boolean autoDownload = actionParameters.getBoolean( @@ -313,7 +314,7 @@ public class ProcessDownloadedMmsAction extends Action { // In either case, we just need to copy the status to the response bundle. status = actionParameters.getInt(KEY_STATUS); rawStatus = actionParameters.getInt(KEY_RAW_STATUS); - mmsUri = actionParameters.getParcelable(KEY_MMS_URI); + mmsUri = actionParameters.getParcelable(KEY_MMS_URI, Uri.class); } final Bundle response = new Bundle(); @@ -335,7 +336,7 @@ public class ProcessDownloadedMmsAction extends Action { final int status = response.getInt(BUNDLE_REQUEST_STATUS); final int rawStatus = response.getInt(BUNDLE_RAW_TELEPHONY_STATUS); - final Uri messageUri = response.getParcelable(BUNDLE_MMS_URI); + final Uri messageUri = response.getParcelable(BUNDLE_MMS_URI, Uri.class); final boolean autoDownload = actionParameters.getBoolean(KEY_AUTO_DOWNLOAD); final String messageId = actionParameters.getString(KEY_MESSAGE_ID); @@ -411,7 +412,8 @@ public class ProcessDownloadedMmsAction extends Action { private MessageData processResult(final int status, final int rawStatus, final Uri mmsUri) { final Context context = Factory.get().getApplicationContext(); final String messageId = actionParameters.getString(KEY_MESSAGE_ID); - final Uri mmsNotificationUri = actionParameters.getParcelable(KEY_NOTIFICATION_URI); + final Uri mmsNotificationUri = actionParameters.getParcelable(KEY_NOTIFICATION_URI, + Uri.class); final String notificationConversationId = actionParameters.getString(KEY_CONVERSATION_ID); final String notificationParticipantId = actionParameters.getString(KEY_PARTICIPANT_ID); final int statusIfFailed = actionParameters.getInt(KEY_STATUS_IF_FAILED); @@ -432,8 +434,8 @@ public class ProcessDownloadedMmsAction extends Action { mms = MmsUtils.loadMms(mmsUri); } - boolean messageInFocusedConversation = false; - boolean messageInObservableConversation = false; + boolean messageInFocusedConversation; + boolean messageInObservableConversation; String conversationId = null; MessageData message = null; final DatabaseWrapper db = DataModel.get().getDatabase(); diff --git a/src/com/android/messaging/datamodel/action/ProcessPendingMessagesAction.java b/src/com/android/messaging/datamodel/action/ProcessPendingMessagesAction.java index 703b468..d58a60f 100644 --- a/src/com/android/messaging/datamodel/action/ProcessPendingMessagesAction.java +++ b/src/com/android/messaging/datamodel/action/ProcessPendingMessagesAction.java @@ -306,8 +306,8 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable { final String selfId) { String toSendMessageId = null; Cursor cursor = null; - int sendingCnt = 0; - int pendingCnt = 0; + int sendingCnt; + int pendingCnt; int failedCnt = 0; db.beginTransaction(); try { @@ -390,8 +390,8 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable { final String selfId) { String toDownloadMessageId = null; Cursor cursor = null; - int downloadingCnt = 0; - int pendingCnt = 0; + int downloadingCnt; + int pendingCnt; db.beginTransaction(); try { // First check if we have any messages already downloading diff --git a/src/com/android/messaging/datamodel/action/ProcessSentMessageAction.java b/src/com/android/messaging/datamodel/action/ProcessSentMessageAction.java index 1988f47..df3e20a 100644 --- a/src/com/android/messaging/datamodel/action/ProcessSentMessageAction.java +++ b/src/com/android/messaging/datamodel/action/ProcessSentMessageAction.java @@ -86,13 +86,13 @@ public class ProcessSentMessageAction extends Action { params.putString(KEY_MESSAGE_ID, extras.getString(SendMessageAction.EXTRA_MESSAGE_ID)); params.putParcelable(KEY_MESSAGE_URI, messageUri); params.putParcelable(KEY_UPDATED_MESSAGE_URI, - extras.getParcelable(SendMessageAction.EXTRA_UPDATED_MESSAGE_URI)); + extras.getParcelable(SendMessageAction.EXTRA_UPDATED_MESSAGE_URI, Uri.class)); params.putInt(KEY_SUB_ID, extras.getInt(SendMessageAction.KEY_SUB_ID, ParticipantData.DEFAULT_SELF_SUB_ID)); params.putInt(KEY_RESULT_CODE, resultCode); params.putInt(KEY_HTTP_STATUS_CODE, extras.getInt(SmsManager.EXTRA_MMS_HTTP_STATUS, 0)); params.putParcelable(KEY_CONTENT_URI, - extras.getParcelable(SendMessageAction.EXTRA_CONTENT_URI)); + extras.getParcelable(SendMessageAction.EXTRA_CONTENT_URI, Uri.class)); params.putByteArray(KEY_RESPONSE, extras.getByteArray(SmsManager.EXTRA_MMS_DATA)); params.putBoolean(KEY_RESPONSE_IMPORTANT, extras.getBoolean(SendMessageAction.EXTRA_RESPONSE_IMPORTANT)); @@ -128,8 +128,9 @@ public class ProcessSentMessageAction extends Action { protected Object executeAction() { final Context context = Factory.get().getApplicationContext(); final String messageId = actionParameters.getString(KEY_MESSAGE_ID); - final Uri messageUri = actionParameters.getParcelable(KEY_MESSAGE_URI); - final Uri updatedMessageUri = actionParameters.getParcelable(KEY_UPDATED_MESSAGE_URI); + final Uri messageUri = actionParameters.getParcelable(KEY_MESSAGE_URI, Uri.class); + final Uri updatedMessageUri = actionParameters.getParcelable(KEY_UPDATED_MESSAGE_URI, + Uri.class); final boolean isSms = actionParameters.getBoolean(KEY_SMS); final boolean sentByPlatform = actionParameters.getBoolean(KEY_SENT_BY_PLATFORM); @@ -140,7 +141,7 @@ public class ProcessSentMessageAction extends Action { if (sentByPlatform) { // Delete temporary file backing the contentUri passed to MMS service - final Uri contentUri = actionParameters.getParcelable(KEY_CONTENT_URI); + final Uri contentUri = actionParameters.getParcelable(KEY_CONTENT_URI, Uri.class); Assert.isTrue(contentUri != null); final File tempFile = MmsFileProvider.getFile(contentUri); long messageSize = 0; diff --git a/src/com/android/messaging/datamodel/action/ReadDraftDataAction.java b/src/com/android/messaging/datamodel/action/ReadDraftDataAction.java index 1dc5817..4dc0bed 100644 --- a/src/com/android/messaging/datamodel/action/ReadDraftDataAction.java +++ b/src/com/android/messaging/datamodel/action/ReadDraftDataAction.java @@ -84,7 +84,8 @@ public class ReadDraftDataAction extends Action implements Parcelable { protected Object executeAction() { final DatabaseWrapper db = DataModel.get().getDatabase(); final String conversationId = actionParameters.getString(KEY_CONVERSATION_ID); - final MessageData incomingDraft = actionParameters.getParcelable(KEY_INCOMING_DRAFT); + final MessageData incomingDraft = actionParameters.getParcelable(KEY_INCOMING_DRAFT, + MessageData.class); final ConversationListItemData conversation = ConversationListItemData.getExistingConversation(db, conversationId); MessageData message = null; diff --git a/src/com/android/messaging/datamodel/action/ReceiveSmsMessageAction.java b/src/com/android/messaging/datamodel/action/ReceiveSmsMessageAction.java index 013c352..a45a9a7 100644 --- a/src/com/android/messaging/datamodel/action/ReceiveSmsMessageAction.java +++ b/src/com/android/messaging/datamodel/action/ReceiveSmsMessageAction.java @@ -59,7 +59,8 @@ public class ReceiveSmsMessageAction extends Action implements Parcelable { @Override protected Object executeAction() { final Context context = Factory.get().getApplicationContext(); - final ContentValues messageValues = actionParameters.getParcelable(KEY_MESSAGE_VALUES); + final ContentValues messageValues = actionParameters.getParcelable(KEY_MESSAGE_VALUES, + ContentValues.class); final DatabaseWrapper db = DataModel.get().getDatabase(); // Get the SIM subscription ID diff --git a/src/com/android/messaging/datamodel/action/SendMessageAction.java b/src/com/android/messaging/datamodel/action/SendMessageAction.java index 2f8d00b..ffac134 100644 --- a/src/com/android/messaging/datamodel/action/SendMessageAction.java +++ b/src/com/android/messaging/datamodel/action/SendMessageAction.java @@ -193,9 +193,9 @@ public class SendMessageAction extends Action implements Parcelable { */ @Override protected Bundle doBackgroundWork() { - final MessageData message = actionParameters.getParcelable(KEY_MESSAGE); + final MessageData message = actionParameters.getParcelable(KEY_MESSAGE, MessageData.class); final String messageId = actionParameters.getString(KEY_MESSAGE_ID); - Uri messageUri = actionParameters.getParcelable(KEY_MESSAGE_URI); + Uri messageUri = actionParameters.getParcelable(KEY_MESSAGE_URI, Uri.class); Uri updatedMessageUri = null; final boolean isSms = message.getProtocol() == MessageData.PROTOCOL_SMS; final int subId = actionParameters.getInt(KEY_SUB_ID, ParticipantData.DEFAULT_SELF_SUB_ID); @@ -294,7 +294,7 @@ public class SendMessageAction extends Action implements Parcelable { @Override protected Object processBackgroundFailure() { final String messageId = actionParameters.getString(KEY_MESSAGE_ID); - final MessageData message = actionParameters.getParcelable(KEY_MESSAGE); + final MessageData message = actionParameters.getParcelable(KEY_MESSAGE, MessageData.class); final boolean isSms = message.getProtocol() == MessageData.PROTOCOL_SMS; final int subId = actionParameters.getInt(KEY_SUB_ID, ParticipantData.DEFAULT_SELF_SUB_ID); final int resultCode = actionParameters.getInt(ProcessSentMessageAction.KEY_RESULT_CODE); diff --git a/src/com/android/messaging/datamodel/action/SyncCursorPair.java b/src/com/android/messaging/datamodel/action/SyncCursorPair.java index 7329b71..d9bf0b3 100644 --- a/src/com/android/messaging/datamodel/action/SyncCursorPair.java +++ b/src/com/android/messaging/datamodel/action/SyncCursorPair.java @@ -489,7 +489,7 @@ class SyncCursorPair { @Override public DatabaseMessage next() { - DatabaseMessage result = null; + DatabaseMessage result; if (mNextSms != null && mNextMms != null) { if (mNextSms.getTimestampInMillis() >= mNextMms.getTimestampInMillis()) { result = mNextSms; diff --git a/src/com/android/messaging/datamodel/action/SyncMessageBatch.java b/src/com/android/messaging/datamodel/action/SyncMessageBatch.java index 68c5ecb..a9880f2 100644 --- a/src/com/android/messaging/datamodel/action/SyncMessageBatch.java +++ b/src/com/android/messaging/datamodel/action/SyncMessageBatch.java @@ -197,7 +197,7 @@ class SyncMessageBatch { public static int bugleStatusForSms(final boolean isOutgoing, final int type, final int status) { - int bugleStatus = MessageData.BUGLE_STATUS_UNKNOWN; + int bugleStatus; // For a message we sync either if (isOutgoing) { // Outgoing message not yet been sent diff --git a/src/com/android/messaging/datamodel/action/SyncMessagesAction.java b/src/com/android/messaging/datamodel/action/SyncMessagesAction.java index 5fed9bb..dbf7f13 100644 --- a/src/com/android/messaging/datamodel/action/SyncMessagesAction.java +++ b/src/com/android/messaging/datamodel/action/SyncMessagesAction.java @@ -272,10 +272,10 @@ public class SyncMessagesAction extends Action implements Parcelable { final long startTimeMillis = SystemClock.elapsedRealtime(); // Number of messages scanned local and remote - int localPos = 0; - int remotePos = 0; - int localTotal = 0; - int remoteTotal = 0; + int localPos; + int remotePos; + int localTotal; + int remoteTotal; // Scan through the messages on both sides and prepare messages for local message table // changes (including adding and deleting) try { @@ -383,11 +383,12 @@ public class SyncMessagesAction extends Action implements Parcelable { } else { // Succeeded final ArrayList smsToAdd = - response.getParcelableArrayList(BUNDLE_KEY_SMS_MESSAGES); + response.getParcelableArrayList(BUNDLE_KEY_SMS_MESSAGES, SmsMessage.class); final ArrayList mmsToAdd = - response.getParcelableArrayList(BUNDLE_KEY_MMS_MESSAGES); + response.getParcelableArrayList(BUNDLE_KEY_MMS_MESSAGES, MmsMessage.class); final ArrayList messagesToDelete = - response.getParcelableArrayList(BUNDLE_KEY_MESSAGES_TO_DELETE); + response.getParcelableArrayList(BUNDLE_KEY_MESSAGES_TO_DELETE, + LocalDatabaseMessage.class); final int messagesUpdated = smsToAdd.size() + mmsToAdd.size() + messagesToDelete.size(); diff --git a/src/com/android/messaging/datamodel/action/WriteDraftMessageAction.java b/src/com/android/messaging/datamodel/action/WriteDraftMessageAction.java index 6efe9c2..77f8508 100644 --- a/src/com/android/messaging/datamodel/action/WriteDraftMessageAction.java +++ b/src/com/android/messaging/datamodel/action/WriteDraftMessageAction.java @@ -53,7 +53,7 @@ public class WriteDraftMessageAction extends Action implements Parcelable { protected Object executeAction() { final DatabaseWrapper db = DataModel.get().getDatabase(); final String conversationId = actionParameters.getString(KEY_CONVERSATION_ID); - final MessageData message = actionParameters.getParcelable(KEY_MESSAGE); + final MessageData message = actionParameters.getParcelable(KEY_MESSAGE, MessageData.class); if (message.getSelfId() == null || message.getParticipantId() == null) { // This could happen when this occurs before the draft message is loaded // In this case, we just use the conversation's current self id as draft's diff --git a/src/com/android/messaging/datamodel/data/DraftMessageData.java b/src/com/android/messaging/datamodel/data/DraftMessageData.java index 95f8f05..67accbc 100644 --- a/src/com/android/messaging/datamodel/data/DraftMessageData.java +++ b/src/com/android/messaging/datamodel/data/DraftMessageData.java @@ -185,7 +185,7 @@ public class DraftMessageData extends BindableData implements ReadDraftDataActio * @return the MessageData for the draft, null if self id is not set */ public MessageData createMessageWithCurrentAttachments(final boolean clearLocalCopy) { - MessageData message = null; + MessageData message; if (getIsMms()) { message = MessageData.createDraftMmsMessage(mConversationId, mSelfId, mMessageText, mMessageSubject); diff --git a/src/com/android/messaging/datamodel/data/MessageData.java b/src/com/android/messaging/datamodel/data/MessageData.java index 5556222..92be4b2 100644 --- a/src/com/android/messaging/datamodel/data/MessageData.java +++ b/src/com/android/messaging/datamodel/data/MessageData.java @@ -837,7 +837,8 @@ public class MessageData implements Parcelable { mParts = new ArrayList<>(); final int partCount = in.readInt(); for (int i = 0; i < partCount; i++) { - mParts.add((MessagePartData) in.readParcelable(MessagePartData.class.getClassLoader())); + mParts.add(in.readParcelable(MessagePartData.class.getClassLoader(), + MessagePartData.class)); } } diff --git a/src/com/android/messaging/datamodel/media/DecodedImageResource.java b/src/com/android/messaging/datamodel/media/DecodedImageResource.java index f5f9112..b79a815 100644 --- a/src/com/android/messaging/datamodel/media/DecodedImageResource.java +++ b/src/com/android/messaging/datamodel/media/DecodedImageResource.java @@ -220,7 +220,6 @@ public class DecodedImageResource extends ImageResource { } finally { if (scaledBitmap != null && scaledBitmap != getBitmap()) { scaledBitmap.recycle(); - scaledBitmap = null; } releaseLock(); release(); diff --git a/src/com/android/messaging/datamodel/media/GifImageResource.java b/src/com/android/messaging/datamodel/media/GifImageResource.java index bff2597..8d13fcf 100644 --- a/src/com/android/messaging/datamodel/media/GifImageResource.java +++ b/src/com/android/messaging/datamodel/media/GifImageResource.java @@ -59,7 +59,7 @@ public class GifImageResource extends ImageResource { @Override public Drawable getDrawable(Resources resources) { try { - return (AnimatedImageDrawable) ImageDecoder.decodeDrawable(mImageDecoderSource); + return ImageDecoder.decodeDrawable(mImageDecoderSource); } catch (final Throwable t) { // Malicious gif images can make the platform throw different kind of throwables, such // as OutOfMemoryError and NullPointerException. Catch them all. diff --git a/src/com/android/messaging/datamodel/media/MediaResourceManager.java b/src/com/android/messaging/datamodel/media/MediaResourceManager.java index 1a14834..82278e6 100644 --- a/src/com/android/messaging/datamodel/media/MediaResourceManager.java +++ b/src/com/android/messaging/datamodel/media/MediaResourceManager.java @@ -157,7 +157,7 @@ public class MediaResourceManager { final MediaRequest mediaRequest) throws Exception { final List> chainedRequests = new ArrayList<>(); - T loadedResource = null; + T loadedResource; // Try fetching from cache first. final T cachedResource = loadMediaFromCache(mediaRequest); if (cachedResource != null) { diff --git a/src/com/android/messaging/datamodel/media/VCardResourceEntry.java b/src/com/android/messaging/datamodel/media/VCardResourceEntry.java index 47f0111..33306f4 100644 --- a/src/com/android/messaging/datamodel/media/VCardResourceEntry.java +++ b/src/com/android/messaging/datamodel/media/VCardResourceEntry.java @@ -222,7 +222,7 @@ public class VCardResourceEntry { if (vcard.getOrganizationList() != null) { for (final OrganizationData organtization : vcard.getOrganizationList()) { - String type = null; + String type; try { type = resources.getString(Organization.getTypeLabelResource( organtization.getType())); diff --git a/src/com/android/messaging/datamodel/media/VideoThumbnailRequest.java b/src/com/android/messaging/datamodel/media/VideoThumbnailRequest.java index 53eebb2..a05f34f 100644 --- a/src/com/android/messaging/datamodel/media/VideoThumbnailRequest.java +++ b/src/com/android/messaging/datamodel/media/VideoThumbnailRequest.java @@ -48,7 +48,7 @@ public class VideoThumbnailRequest extends ImageRequest mContentTypeMap = null; + private static SimpleArrayMap mContentTypeMap; static { mContentTypeMap = new SimpleArrayMap<>(); @@ -469,7 +469,7 @@ public class PduComposer { } private EncodedStringValue appendAddressType(final EncodedStringValue address) { - EncodedStringValue temp = null; + EncodedStringValue temp; try { final int addressType = checkAddressType(address.getString()); @@ -1065,7 +1065,7 @@ public class PduComposer { try { final byte[] buffer = new byte[PDU_COMPOSER_BLOCK_SIZE]; cr = mResolver.openInputStream(part.getDataUri()); - int len = 0; + int len; while ((len = cr.read(buffer)) != -1) { mMessage.write(buffer, 0, len); mPosition += len; diff --git a/src/com/android/messaging/mmslib/pdu/PduPersister.java b/src/com/android/messaging/mmslib/pdu/PduPersister.java index 54573e3..bc37c02 100644 --- a/src/com/android/messaging/mmslib/pdu/PduPersister.java +++ b/src/com/android/messaging/mmslib/pdu/PduPersister.java @@ -373,7 +373,7 @@ public class PduPersister { Uri.parse("content://mms/" + msgId + "/part"), PART_PROJECTION, null, null, null); - PduPart[] parts = null; + PduPart[] parts; try { if ((c == null) || (c.getCount() == 0)) { @@ -560,7 +560,7 @@ public class PduPersister { */ public GenericPdu load(final Uri uri) throws MmsException { GenericPdu pdu = null; - PduCacheEntry cacheEntry = null; + PduCacheEntry cacheEntry; int msgBox = 0; final long threadId = -1; try { @@ -859,7 +859,7 @@ public class PduPersister { OutputStream os = null; InputStream is = null; DrmConvertSession drmConvertSession = null; - Uri dataUri = null; + Uri dataUri; String path = null; try { @@ -936,7 +936,7 @@ public class PduPersister { } final byte[] buffer = new byte[8192]; - for (int len = 0; (len = is.read(buffer)) != -1; ) { + for (int len; (len = is.read(buffer)) != -1; ) { if (!isDrm) { os.write(buffer, 0, len); } else { @@ -955,7 +955,6 @@ public class PduPersister { if (!isDrm) { os.write(data); } else { - dataUri = uri; final byte[] convertedData = drmConvertSession.convert(data, data.length); if (convertedData != null) { os.write(convertedData, 0, convertedData.length); @@ -1093,7 +1092,7 @@ public class PduPersister { PDU_CACHE_INSTANCE.purge(uri); final PduHeaders header = pdu.getPduHeaders(); - PduBody body = null; + PduBody body; ContentValues values = new ContentValues(); // Mark new messages as seen in the telephony database so that we don't have to diff --git a/src/com/android/messaging/mmslib/util/DrmConvertSession.java b/src/com/android/messaging/mmslib/util/DrmConvertSession.java index 688720a..63e6c45 100644 --- a/src/com/android/messaging/mmslib/util/DrmConvertSession.java +++ b/src/com/android/messaging/mmslib/util/DrmConvertSession.java @@ -86,7 +86,7 @@ public class DrmConvertSession { public byte[] convert(byte[] inBuffer, int size) { byte[] result = null; if (inBuffer != null) { - DrmConvertedStatus convertedStatus = null; + DrmConvertedStatus convertedStatus; try { if (size != inBuffer.length) { byte[] buf = new byte[size]; @@ -125,7 +125,7 @@ public class DrmConvertSession { * Downloads.Impl.STATUS_UNKNOWN_ERROR if a general error occurred. */ public int close(String filename) { - DrmConvertedStatus convertedStatus = null; + DrmConvertedStatus convertedStatus; int result = Downloads.Impl.STATUS_UNKNOWN_ERROR; if (mDrmClient != null && mConvertSessionId >= 0) { try { diff --git a/src/com/android/messaging/mmslib/util/PduCache.java b/src/com/android/messaging/mmslib/util/PduCache.java index 68e326d..50eee74 100644 --- a/src/com/android/messaging/mmslib/util/PduCache.java +++ b/src/com/android/messaging/mmslib/util/PduCache.java @@ -188,7 +188,7 @@ public final class PduCache extends AbstractCache { */ private Uri normalizeKey(Uri uri) { int match = URI_MATCHER.match(uri); - Uri normalizedKey = null; + Uri normalizedKey; switch (match) { case MMS_ALL_ID: diff --git a/src/com/android/messaging/receiver/SendStatusReceiver.java b/src/com/android/messaging/receiver/SendStatusReceiver.java index 8d2e10f..b138639 100644 --- a/src/com/android/messaging/receiver/SendStatusReceiver.java +++ b/src/com/android/messaging/receiver/SendStatusReceiver.java @@ -82,7 +82,7 @@ public class SendStatusReceiver extends BroadcastReceiver { LogUtil.e(LogUtil.BUGLE_TAG, "SendStatusReceiver: empty report message"); return; } - int status = Sms.STATUS_COMPLETE; + int status; try { final String format = intent.getStringExtra("format"); status = smsMessage.getStatus(); diff --git a/src/com/android/messaging/sms/BugleApnSettingsLoader.java b/src/com/android/messaging/sms/BugleApnSettingsLoader.java index 9c8cd50..7305424 100644 --- a/src/com/android/messaging/sms/BugleApnSettingsLoader.java +++ b/src/com/android/messaging/sms/BugleApnSettingsLoader.java @@ -466,7 +466,7 @@ public class BugleApnSettingsLoader implements ApnSettingsLoader { LogUtil.i(LogUtil.BUGLE_TAG, "Loading APNs from local APN table"); final SQLiteDatabase database = ApnDatabase.getApnDatabase().getWritableDatabase(); final String mccMnc = PhoneUtils.getMccMncString(PhoneUtils.getDefault().getMccMnc()); - Cursor cursor = null; + Cursor cursor; cursor = queryLocalDatabase(database, mccMnc, apnName); if (cursor == null) { cursor = queryLocalDatabase(database, mccMnc, null/*apnName*/); @@ -513,7 +513,7 @@ public class BugleApnSettingsLoader implements ApnSettingsLoader { selection = SELECTION_NUMERIC + " AND " + SELECTION_APN; selectionArgs = new String[] { numeric, apnName }; } - Cursor cursor = null; + Cursor cursor; try { cursor = db.query(ApnDatabase.APN_TABLE, APN_PROJECTION_LOCAL, selection, selectionArgs, null/*groupBy*/, null/*having*/, ORDER_BY, null/*limit*/); diff --git a/src/com/android/messaging/sms/DatabaseMessages.java b/src/com/android/messaging/sms/DatabaseMessages.java index 7cb4b92..a733585 100644 --- a/src/com/android/messaging/sms/DatabaseMessages.java +++ b/src/com/android/messaging/sms/DatabaseMessages.java @@ -476,7 +476,7 @@ public class DatabaseMessages { mParts = new ArrayList<>(); mPartsProcessed = false; for (int i = 0; i < nParts; i++) { - mParts.add((MmsPart) in.readParcelable(getClass().getClassLoader())); + mParts.add(in.readParcelable(getClass().getClassLoader())); } } diff --git a/src/com/android/messaging/sms/MmsUtils.java b/src/com/android/messaging/sms/MmsUtils.java index 6ab6331..7f12ac4 100644 --- a/src/com/android/messaging/sms/MmsUtils.java +++ b/src/com/android/messaging/sms/MmsUtils.java @@ -1544,7 +1544,7 @@ public class MmsUtils { public static int bugleStatusForMms(final boolean isOutgoing, final boolean isNotification, final int messageBox) { - int bugleStatus = MessageData.BUGLE_STATUS_UNKNOWN; + int bugleStatus; // For a message we sync either if (isOutgoing) { if (messageBox == Mms.MESSAGE_BOX_OUTBOX || messageBox == Mms.MESSAGE_BOX_FAILED) { diff --git a/src/com/android/messaging/ui/AttachmentPreview.java b/src/com/android/messaging/ui/AttachmentPreview.java index 38f74c6..6db84c6 100644 --- a/src/com/android/messaging/ui/AttachmentPreview.java +++ b/src/com/android/messaging/ui/AttachmentPreview.java @@ -70,10 +70,10 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi @Override protected void onFinishInflate() { super.onFinishInflate(); - mCloseButton = (ImageButton) findViewById(R.id.close_button); + mCloseButton = findViewById(R.id.close_button); mCloseButton.setOnClickListener(view -> mComposeMessageView.clearAttachments()); - mAttachmentView = (FrameLayout) findViewById(R.id.attachment_view); + mAttachmentView = findViewById(R.id.attachment_view); // The attachment preview is a scroll view so that it can show the bottom portion of the // attachment whenever the space is tight (e.g. when in landscape mode). Per design diff --git a/src/com/android/messaging/ui/AttachmentPreviewFactory.java b/src/com/android/messaging/ui/AttachmentPreviewFactory.java index 13b7fdc..be82690 100644 --- a/src/com/android/messaging/ui/AttachmentPreviewFactory.java +++ b/src/com/android/messaging/ui/AttachmentPreviewFactory.java @@ -66,7 +66,7 @@ public class AttachmentPreviewFactory { final int viewType, final boolean startImageRequest, @Nullable final OnAttachmentClickListener clickListener) { final String contentType = attachmentData.getContentType(); - View attachmentView = null; + View attachmentView; if (attachmentData instanceof PendingAttachmentData) { attachmentView = createPendingAttachmentPreview(layoutInflater, parent, (PendingAttachmentData) attachmentData); @@ -85,7 +85,7 @@ public class AttachmentPreviewFactory { } // Some views have a caption, set the text/visibility if one exists - final TextView captionView = (TextView) attachmentView.findViewById(R.id.caption); + final TextView captionView = attachmentView.findViewById(R.id.caption); if (captionView != null) { final String caption = attachmentData.getText(); captionView.setVisibility(TextUtils.isEmpty(caption) ? View.GONE : View.VISIBLE); @@ -159,8 +159,7 @@ public class AttachmentPreviewFactory { break; } final View view = layoutInflater.inflate(layoutId, parent, false /* attachToRoot */); - final AsyncImageView imageView = (AsyncImageView) view.findViewById( - R.id.attachment_image_view); + final AsyncImageView imageView = view.findViewById(R.id.attachment_image_view); int maxWidth = imageView.getMaxWidth(); int maxHeight = imageView.getMaxHeight(); if (viewType == TYPE_CHOOSER_GRID) { @@ -187,8 +186,7 @@ public class AttachmentPreviewFactory { final ViewGroup parent, final PendingAttachmentData attachmentData) { final View pendingItemView = layoutInflater.inflate(R.layout.attachment_pending_item, parent, false); - final ImageView imageView = (ImageView) - pendingItemView.findViewById(R.id.pending_item_view); + final ImageView imageView = pendingItemView.findViewById(R.id.pending_item_view); final ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams(); final int defaultSize = layoutInflater.getContext().getResources().getDimensionPixelSize( R.dimen.pending_attachment_size); @@ -218,8 +216,7 @@ public class AttachmentPreviewFactory { break; } final View view = layoutInflater.inflate(layoutId, parent, false /* attachToRoot */); - final PersonItemView vcardPreview = (PersonItemView) view.findViewById( - R.id.vcard_attachment_view); + final PersonItemView vcardPreview = view.findViewById(R.id.vcard_attachment_view); vcardPreview.setAvatarOnly(viewType != AttachmentPreviewFactory.TYPE_SINGLE); vcardPreview.bind(DataModel.get().createVCardContactItemData(layoutInflater.getContext(), attachmentData)); @@ -261,8 +258,7 @@ public class AttachmentPreviewFactory { break; } final View view = layoutInflater.inflate(layoutId, parent, false /* attachToRoot */); - final AudioAttachmentView audioView = (AudioAttachmentView) - view.findViewById(R.id.audio_attachment_view); + final AudioAttachmentView audioView = view.findViewById(R.id.audio_attachment_view); audioView.bindMessagePartData( attachmentData, false /* incoming */, false /* showAsSelected */); return view; diff --git a/src/com/android/messaging/ui/AudioAttachmentPlayPauseButton.java b/src/com/android/messaging/ui/AudioAttachmentPlayPauseButton.java index 724c4fe..ac97ee0 100644 --- a/src/com/android/messaging/ui/AudioAttachmentPlayPauseButton.java +++ b/src/com/android/messaging/ui/AudioAttachmentPlayPauseButton.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 The Android Open Source Project + * Copyright (C) 2025 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. @@ -38,8 +39,8 @@ public class AudioAttachmentPlayPauseButton extends ViewSwitcher { @Override protected void onFinishInflate() { super.onFinishInflate(); - mPlayButton = (ImageView) findViewById(R.id.play_button); - mPauseButton = (ImageView) findViewById(R.id.pause_button); + mPlayButton = findViewById(R.id.play_button); + mPauseButton = findViewById(R.id.pause_button); updateAppearance(); } diff --git a/src/com/android/messaging/ui/AudioAttachmentView.java b/src/com/android/messaging/ui/AudioAttachmentView.java index a533a6f..dc5f353 100644 --- a/src/com/android/messaging/ui/AudioAttachmentView.java +++ b/src/com/android/messaging/ui/AudioAttachmentView.java @@ -104,9 +104,9 @@ public class AudioAttachmentView extends LinearLayout { protected void onFinishInflate() { super.onFinishInflate(); - mPlayPauseButton = (AudioAttachmentPlayPauseButton) findViewById(R.id.play_pause_button); - mChronometer = (PausableChronometer) findViewById(R.id.timer); - mProgressBar = (AudioPlaybackProgressBar) findViewById(R.id.progress); + mPlayPauseButton = findViewById(R.id.play_pause_button); + mChronometer = findViewById(R.id.timer); + mProgressBar = findViewById(R.id.progress); mPlayPauseButton.setOnClickListener(v -> { // Has the MediaPlayer already been prepared? if (mMediaPlayer != null && mPrepared) { @@ -352,12 +352,12 @@ public class AudioAttachmentView extends LinearLayout { mProgressBar.setVisibility(GONE); mChronometer.setVisibility(GONE); ((MarginLayoutParams) mPlayPauseButton.getLayoutParams()).setMargins(0, 0, 0, 0); - final ImageView playButton = (ImageView) findViewById(R.id.play_button); + final ImageView playButton = findViewById(R.id.play_button); final Resources res = getResources(); final Resources.Theme theme = getContext().getTheme(); playButton.setImageDrawable( ResourcesCompat.getDrawable(res, R.drawable.ic_preview_play, theme)); - final ImageView pauseButton = (ImageView) findViewById(R.id.pause_button); + final ImageView pauseButton = findViewById(R.id.pause_button); pauseButton.setImageDrawable( ResourcesCompat.getDrawable(res, R.drawable.ic_preview_pause, theme)); break; diff --git a/src/com/android/messaging/ui/BlockedParticipantListItemView.java b/src/com/android/messaging/ui/BlockedParticipantListItemView.java index 84676cc..c10329f 100644 --- a/src/com/android/messaging/ui/BlockedParticipantListItemView.java +++ b/src/com/android/messaging/ui/BlockedParticipantListItemView.java @@ -42,8 +42,8 @@ public class BlockedParticipantListItemView extends LinearLayout { @Override protected void onFinishInflate() { super.onFinishInflate(); - mNameTextView = (TextView) findViewById(R.id.name); - mContactIconView = (ContactIconView) findViewById(R.id.contact_icon); + mNameTextView = findViewById(R.id.name); + mContactIconView = findViewById(R.id.contact_icon); setOnClickListener(v -> mData.unblock(getContext())); } diff --git a/src/com/android/messaging/ui/BlockedParticipantsFragment.java b/src/com/android/messaging/ui/BlockedParticipantsFragment.java index 6dcb8f4..37ddb1c 100644 --- a/src/com/android/messaging/ui/BlockedParticipantsFragment.java +++ b/src/com/android/messaging/ui/BlockedParticipantsFragment.java @@ -57,7 +57,7 @@ public class BlockedParticipantsFragment extends Fragment final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.blocked_participants_fragment, container, false); - mListView = (ListView) view.findViewById(android.R.id.list); + mListView = view.findViewById(android.R.id.list); mAdapter = new BlockedParticipantListAdapter(getActivity(), null); mListView.setAdapter(mAdapter); mBinding.bind(DataModel.get().createBlockedParticipantsData(getActivity(), this)); diff --git a/src/com/android/messaging/ui/ClassZeroActivity.java b/src/com/android/messaging/ui/ClassZeroActivity.java index 65478d4..3087b14 100644 --- a/src/com/android/messaging/ui/ClassZeroActivity.java +++ b/src/com/android/messaging/ui/ClassZeroActivity.java @@ -82,7 +82,8 @@ public class ClassZeroActivity extends Activity { private boolean queueMsgFromIntent(final Intent msgIntent) { final ContentValues messageValues = - msgIntent.getParcelableExtra(UIIntents.UI_INTENT_EXTRA_MESSAGE_VALUES); + msgIntent.getParcelableExtra(UIIntents.UI_INTENT_EXTRA_MESSAGE_VALUES, + ContentValues.class); // that takes the format argument is a hidden API right now. final String message = messageValues.getAsString(Sms.BODY); if (TextUtils.isEmpty(message)) { diff --git a/src/com/android/messaging/ui/CustomHeaderPagerListViewHolder.java b/src/com/android/messaging/ui/CustomHeaderPagerListViewHolder.java index 1268c53..51bd873 100644 --- a/src/com/android/messaging/ui/CustomHeaderPagerListViewHolder.java +++ b/src/com/android/messaging/ui/CustomHeaderPagerListViewHolder.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 The Android Open Source Project + * Copyright (C) 2025 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. @@ -51,7 +52,7 @@ public abstract class CustomHeaderPagerListViewHolder extends BasePagerViewHolde getLayoutResId(), null /* root */, false /* attachToRoot */); - final ListView listView = (ListView) view.findViewById(getListViewResId()); + final ListView listView = view.findViewById(getListViewResId()); listView.setAdapter(mListAdapter); listView.setOnScrollListener(new OnScrollListener() { @Override @@ -90,11 +91,11 @@ public abstract class CustomHeaderPagerListViewHolder extends BasePagerViewHolde */ private void maybeSetEmptyView() { if (mView != null && mListCursorInitialized) { - final ListEmptyView emptyView = (ListEmptyView) mView.findViewById(getEmptyViewResId()); + final ListEmptyView emptyView = mView.findViewById(getEmptyViewResId()); if (emptyView != null) { emptyView.setTextHint(getEmptyViewTitleResId()); emptyView.setImageHint(getEmptyViewImageResId()); - final ListView listView = (ListView) mView.findViewById(getListViewResId()); + final ListView listView = mView.findViewById(getListViewResId()); listView.setEmptyView(emptyView); } } diff --git a/src/com/android/messaging/ui/CustomHeaderViewPager.java b/src/com/android/messaging/ui/CustomHeaderViewPager.java index ead254c..448f0d1 100644 --- a/src/com/android/messaging/ui/CustomHeaderViewPager.java +++ b/src/com/android/messaging/ui/CustomHeaderViewPager.java @@ -45,8 +45,8 @@ public class CustomHeaderViewPager extends LinearLayout { inflater.inflate(R.layout.custom_header_view_pager, this, true); setOrientation(LinearLayout.VERTICAL); - mTabstrip = (ViewPagerTabs) findViewById(R.id.tab_strip); - mViewPager = (ViewPager) findViewById(R.id.pager); + mTabstrip = findViewById(R.id.tab_strip); + mViewPager = findViewById(R.id.pager); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true); diff --git a/src/com/android/messaging/ui/FixedViewPagerAdapter.java b/src/com/android/messaging/ui/FixedViewPagerAdapter.java index dc9d4f7..c2da7da 100644 --- a/src/com/android/messaging/ui/FixedViewPagerAdapter.java +++ b/src/com/android/messaging/ui/FixedViewPagerAdapter.java @@ -108,7 +108,7 @@ public class FixedViewPagerAdapter extends PagerAdapt ((Bundle) state).setClassLoader(Factory.get().getApplicationContext().getClassLoader()); for (int i = 0; i < mViewHolders.length; i++) { final Parcelable pageState = restoredViewHolderState - .getParcelable(getInstanceStateKeyForPage(i)); + .getParcelable(getInstanceStateKeyForPage(i), Parcelable.class); getViewHolder(i).restoreState(pageState); } } else { diff --git a/src/com/android/messaging/ui/LicenseActivity.java b/src/com/android/messaging/ui/LicenseActivity.java index a28da81..048bb55 100644 --- a/src/com/android/messaging/ui/LicenseActivity.java +++ b/src/com/android/messaging/ui/LicenseActivity.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 The Android Open Source Project + * Copyright (C) 2025 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. @@ -29,7 +30,7 @@ public class LicenseActivity extends Activity { public void onCreate(final Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.license_activity); - final WebView webView = (WebView) findViewById(R.id.content); + final WebView webView = findViewById(R.id.content); webView.loadUrl(LICENSE_URL); } } diff --git a/src/com/android/messaging/ui/LineWrapLayout.java b/src/com/android/messaging/ui/LineWrapLayout.java index 06c3fde..3de6652 100644 --- a/src/com/android/messaging/ui/LineWrapLayout.java +++ b/src/com/android/messaging/ui/LineWrapLayout.java @@ -76,7 +76,6 @@ public class LineWrapLayout extends ViewGroup { currLineHeight = 0; x = startPadding; currLineWidth = 0; - startMargin = 0; } x += childMeasuredWidth; diff --git a/src/com/android/messaging/ui/ListEmptyView.java b/src/com/android/messaging/ui/ListEmptyView.java index 8cf3049..0406564 100644 --- a/src/com/android/messaging/ui/ListEmptyView.java +++ b/src/com/android/messaging/ui/ListEmptyView.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 The Android Open Source Project + * Copyright (C) 2025 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. @@ -40,8 +41,8 @@ public class ListEmptyView extends LinearLayout { protected void onFinishInflate() { super.onFinishInflate(); - mEmptyImageHint = (ImageView) findViewById(R.id.empty_image_hint); - mEmptyTextHint = (TextView) findViewById(R.id.empty_text_hint); + mEmptyImageHint = findViewById(R.id.empty_image_hint); + mEmptyTextHint = findViewById(R.id.empty_text_hint); } public void setImageHint(final int resId) { diff --git a/src/com/android/messaging/ui/OrientedBitmapDrawable.java b/src/com/android/messaging/ui/OrientedBitmapDrawable.java index 9242668..600ff2a 100644 --- a/src/com/android/messaging/ui/OrientedBitmapDrawable.java +++ b/src/com/android/messaging/ui/OrientedBitmapDrawable.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 The Android Open Source Project + * Copyright (C) 2025 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. @@ -98,7 +99,7 @@ public class OrientedBitmapDrawable extends BitmapDrawable { canvas.save(); canvas.scale(mOrientationParams.scaleX, mOrientationParams.scaleY, mCenterX, mCenterY); canvas.rotate(mOrientationParams.rotation, mCenterX, mCenterY); - canvas.drawBitmap(getBitmap(), (Rect) null, mDstRect, getPaint()); + canvas.drawBitmap(getBitmap(), null, mDstRect, getPaint()); canvas.restore(); } } diff --git a/src/com/android/messaging/ui/PermissionCheckActivity.java b/src/com/android/messaging/ui/PermissionCheckActivity.java index 06f826a..1f05c33 100644 --- a/src/com/android/messaging/ui/PermissionCheckActivity.java +++ b/src/com/android/messaging/ui/PermissionCheckActivity.java @@ -58,10 +58,10 @@ public class PermissionCheckActivity extends Activity { findViewById(R.id.exit).setOnClickListener(view -> finish()); - mNextView = (TextView) findViewById(R.id.next); + mNextView = findViewById(R.id.next); mNextView.setOnClickListener(view -> tryRequestPermission()); - mSettingsView = (TextView) findViewById(R.id.settings); + mSettingsView = findViewById(R.id.settings); mSettingsView.setOnClickListener(view -> { final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse(PACKAGE_URI_PREFIX + getPackageName())); diff --git a/src/com/android/messaging/ui/PersonItemView.java b/src/com/android/messaging/ui/PersonItemView.java index a521d1a..9959421 100644 --- a/src/com/android/messaging/ui/PersonItemView.java +++ b/src/com/android/messaging/ui/PersonItemView.java @@ -68,9 +68,9 @@ public class PersonItemView extends LinearLayout implements PersonItemDataListen @Override protected void onFinishInflate() { super.onFinishInflate(); - mNameTextView = (TextView) findViewById(R.id.name); - mDetailsTextView = (TextView) findViewById(R.id.details); - mContactIconView = (ContactIconView) findViewById(R.id.contact_icon); + mNameTextView = findViewById(R.id.name); + mDetailsTextView = findViewById(R.id.details); + mContactIconView = findViewById(R.id.contact_icon); mDetailsContainer = findViewById(R.id.details_container); mNameTextView.addOnLayoutChangeListener(this); } diff --git a/src/com/android/messaging/ui/SnackBar.java b/src/com/android/messaging/ui/SnackBar.java index 6c1e150..20b3e69 100644 --- a/src/com/android/messaging/ui/SnackBar.java +++ b/src/com/android/messaging/ui/SnackBar.java @@ -214,9 +214,9 @@ public class SnackBar { mParentView = builder.mParentView; mInteractions = Objects.requireNonNullElseGet(builder.mInteractions, ArrayList::new); - mActionTextView = (TextView) mRootView.findViewById(R.id.snack_bar_action); - mMessageView = (TextView) mRootView.findViewById(R.id.snack_bar_message); - mMessageWrapper = (FrameLayout) mRootView.findViewById(R.id.snack_bar_message_wrapper); + mActionTextView = mRootView.findViewById(R.id.snack_bar_action); + mMessageView = mRootView.findViewById(R.id.snack_bar_message); + mMessageWrapper = mRootView.findViewById(R.id.snack_bar_message_wrapper); setUpButton(); setUpTextLines(); diff --git a/src/com/android/messaging/ui/VCardDetailActivity.java b/src/com/android/messaging/ui/VCardDetailActivity.java index 4e299b3..84ae5c1 100644 --- a/src/com/android/messaging/ui/VCardDetailActivity.java +++ b/src/com/android/messaging/ui/VCardDetailActivity.java @@ -47,7 +47,7 @@ public class VCardDetailActivity extends BugleActionBarActivity @NonNull final Fragment fragment) { if (fragment instanceof VCardDetailFragment) { final Uri vCardUri = - getIntent().getParcelableExtra(UIIntents.UI_INTENT_EXTRA_VCARD_URI); + getIntent().getParcelableExtra(UIIntents.UI_INTENT_EXTRA_VCARD_URI, Uri.class); Assert.notNull(vCardUri); final VCardDetailFragment vCardDetailFragment = (VCardDetailFragment) fragment; vCardDetailFragment.setVCardUri(vCardUri); diff --git a/src/com/android/messaging/ui/VCardDetailFragment.java b/src/com/android/messaging/ui/VCardDetailFragment.java index e7ddb7c..fea281d 100644 --- a/src/com/android/messaging/ui/VCardDetailFragment.java +++ b/src/com/android/messaging/ui/VCardDetailFragment.java @@ -77,7 +77,7 @@ public class VCardDetailFragment extends Fragment implements PersonItemDataListe final Bundle savedInstanceState) { Assert.notNull(mVCardUri); final View view = inflater.inflate(R.layout.vcard_detail_fragment, container, false); - mListView = (ExpandableListView) view.findViewById(R.id.list); + mListView = view.findViewById(R.id.list); mListView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { mListView.setIndicatorBounds(mListView.getWidth() - getResources(). diff --git a/src/com/android/messaging/ui/VideoThumbnailView.java b/src/com/android/messaging/ui/VideoThumbnailView.java index d3b57df..78c312f 100644 --- a/src/com/android/messaging/ui/VideoThumbnailView.java +++ b/src/com/android/messaging/ui/VideoThumbnailView.java @@ -113,7 +113,7 @@ public class VideoThumbnailView extends FrameLayout { mVideoView = null; } - mPlayButton = (ImageButton) findViewById(R.id.video_thumbnail_play_button); + mPlayButton = findViewById(R.id.video_thumbnail_play_button); if (loop) { mPlayButton.setVisibility(View.GONE); } else { @@ -136,7 +136,7 @@ public class VideoThumbnailView extends FrameLayout { }); } - mThumbnailImage = (AsyncImageView) findViewById(R.id.video_thumbnail_image); + mThumbnailImage = findViewById(R.id.video_thumbnail_image); if (mAllowCrop) { mThumbnailImage.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; mThumbnailImage.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; @@ -268,8 +268,8 @@ public class VideoThumbnailView extends FrameLayout { super.onMeasure(widthMeasureSpec, heightMeasureSpec); return; } - int desiredWidth = 1; - int desiredHeight = 1; + int desiredWidth; + int desiredHeight; if (mVideoView != null) { mVideoView.measure(widthMeasureSpec, heightMeasureSpec); } diff --git a/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java b/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java index bbfc5f9..bbfa0f0 100644 --- a/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java +++ b/src/com/android/messaging/ui/appsettings/ApplicationSettingsActivity.java @@ -118,7 +118,7 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity { mSmsEnabledPrefKey = getString(R.string.sms_enabled_pref_key); mSmsEnabledPreference = findPreference(mSmsEnabledPrefKey); - final PreferenceScreen advancedScreen = (PreferenceScreen) findPreference( + final PreferenceScreen advancedScreen = findPreference( getString(R.string.advanced_pref_key)); final boolean topLevel = getActivity().getIntent().getBooleanExtra( UIIntents.UI_INTENT_EXTRA_TOP_LEVEL_SETTINGS, false); @@ -134,7 +134,7 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity { @Override public boolean onPreferenceTreeClick(@NonNull Preference preference) { - if (preference.getKey() == mNotificationsPreferenceKey) { + if (preference.getKey().equals(mNotificationsPreferenceKey)) { Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS); intent.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName()); startActivity(intent); diff --git a/src/com/android/messaging/ui/appsettings/GroupMmsSettingDialog.java b/src/com/android/messaging/ui/appsettings/GroupMmsSettingDialog.java index b774f3f..4cd654f 100644 --- a/src/com/android/messaging/ui/appsettings/GroupMmsSettingDialog.java +++ b/src/com/android/messaging/ui/appsettings/GroupMmsSettingDialog.java @@ -66,10 +66,8 @@ public class GroupMmsSettingDialog { final LayoutInflater inflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View rootView = inflater.inflate(R.layout.group_mms_setting_dialog, null, false); - final RadioButton disableButton = (RadioButton) - rootView.findViewById(R.id.disable_group_mms_button); - final RadioButton enableButton = (RadioButton) - rootView.findViewById(R.id.enable_group_mms_button); + final RadioButton disableButton = rootView.findViewById(R.id.disable_group_mms_button); + final RadioButton enableButton = rootView.findViewById(R.id.enable_group_mms_button); disableButton.setOnClickListener(view -> changeGroupMmsSettings(false)); enableButton.setOnClickListener(view -> changeGroupMmsSettings(true)); final boolean mmsEnabled = BuglePrefs.getSubscriptionPrefs(mSubId).getBoolean( diff --git a/src/com/android/messaging/ui/appsettings/PerSubscriptionSettingsActivity.java b/src/com/android/messaging/ui/appsettings/PerSubscriptionSettingsActivity.java index 9ff3eaa..549b8b4 100644 --- a/src/com/android/messaging/ui/appsettings/PerSubscriptionSettingsActivity.java +++ b/src/com/android/messaging/ui/appsettings/PerSubscriptionSettingsActivity.java @@ -95,10 +95,10 @@ public class PerSubscriptionSettingsActivity extends BugleActionBarActivity { addPreferencesFromResource(R.xml.preferences_per_subscription); mPhoneNumberKey = getString(R.string.mms_phone_number_pref_key); - mPhoneNumberPreference = (PhoneNumberPreference) findPreference(mPhoneNumberKey); - final PreferenceCategory advancedCategory = (PreferenceCategory) + mPhoneNumberPreference = findPreference(mPhoneNumberKey); + final PreferenceCategory advancedCategory = findPreference(getString(R.string.advanced_category_pref_key)); - final PreferenceCategory mmsCategory = (PreferenceCategory) + final PreferenceCategory mmsCategory = findPreference(getString(R.string.mms_messaging_category_pref_key)); mPhoneNumberPreference.setDefaultPhoneNumber( diff --git a/src/com/android/messaging/ui/appsettings/SettingsActivity.java b/src/com/android/messaging/ui/appsettings/SettingsActivity.java index dbcee46..31b21a0 100644 --- a/src/com/android/messaging/ui/appsettings/SettingsActivity.java +++ b/src/com/android/messaging/ui/appsettings/SettingsActivity.java @@ -98,7 +98,7 @@ public class SettingsActivity extends BugleActionBarActivity { public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.settings_fragment, container, false); - mListView = (ListView) view.findViewById(android.R.id.list); + mListView = view.findViewById(android.R.id.list); mAdapter = new SettingsListAdapter(getActivity()); mListView.setAdapter(mAdapter); return view; @@ -144,8 +144,8 @@ public class SettingsActivity extends BugleActionBarActivity { R.layout.settings_item_view, parent, false); } final SettingsItem item = getItem(position); - final TextView titleTextView = (TextView) itemView.findViewById(R.id.title); - final TextView subtitleTextView = (TextView) itemView.findViewById(R.id.subtitle); + final TextView titleTextView = itemView.findViewById(R.id.title); + final TextView subtitleTextView = itemView.findViewById(R.id.subtitle); final String summaryText = item.getDisplayDetail(); titleTextView.setText(item.getDisplayName()); if (!TextUtils.isEmpty(summaryText)) { diff --git a/src/com/android/messaging/ui/attachmentchooser/AttachmentChooserFragment.java b/src/com/android/messaging/ui/attachmentchooser/AttachmentChooserFragment.java index 980fae4..3d9c77d 100644 --- a/src/com/android/messaging/ui/attachmentchooser/AttachmentChooserFragment.java +++ b/src/com/android/messaging/ui/attachmentchooser/AttachmentChooserFragment.java @@ -63,7 +63,7 @@ public class AttachmentChooserFragment extends Fragment implements DraftMessageD public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.attachment_chooser_fragment, container, false); - mAttachmentGridView = (AttachmentGridView) view.findViewById(R.id.grid); + mAttachmentGridView = view.findViewById(R.id.grid); mAdapter = new AttachmentGridAdapter(getActivity()); mAttachmentGridView.setAdapter(mAdapter); mAttachmentGridView.setHost(this); diff --git a/src/com/android/messaging/ui/attachmentchooser/AttachmentGridItemView.java b/src/com/android/messaging/ui/attachmentchooser/AttachmentGridItemView.java index 3ee02d0..3e51d0b 100644 --- a/src/com/android/messaging/ui/attachmentchooser/AttachmentGridItemView.java +++ b/src/com/android/messaging/ui/attachmentchooser/AttachmentGridItemView.java @@ -52,8 +52,8 @@ public class AttachmentGridItemView extends FrameLayout { @Override protected void onFinishInflate() { super.onFinishInflate(); - mAttachmentViewContainer = (FrameLayout) findViewById(R.id.attachment_container); - mCheckBox = (CheckBox) findViewById(R.id.checkbox); + mAttachmentViewContainer = findViewById(R.id.attachment_container); + mCheckBox = findViewById(R.id.checkbox); mCheckBox.setOnClickListener(v -> mHostInterface.onItemCheckedChanged( AttachmentGridItemView.this, mAttachmentData)); setOnClickListener(v -> mHostInterface.onItemClicked(AttachmentGridItemView.this, diff --git a/src/com/android/messaging/ui/attachmentchooser/AttachmentGridView.java b/src/com/android/messaging/ui/attachmentchooser/AttachmentGridView.java index d092e51..f1c7d91 100644 --- a/src/com/android/messaging/ui/attachmentchooser/AttachmentGridView.java +++ b/src/com/android/messaging/ui/attachmentchooser/AttachmentGridView.java @@ -142,8 +142,8 @@ public class AttachmentGridView extends GridView implements final int partCount = in.readInt(); unselectedParts = new MessagePartData[partCount]; for (int i = 0; i < partCount; i++) { - unselectedParts[i] = ((MessagePartData) in.readParcelable( - MessagePartData.class.getClassLoader())); + unselectedParts[i] = in.readParcelable(MessagePartData.class.getClassLoader(), + MessagePartData.class); } } diff --git a/src/com/android/messaging/ui/contact/AddContactsConfirmationDialog.java b/src/com/android/messaging/ui/contact/AddContactsConfirmationDialog.java index 86d7391..48368c6 100644 --- a/src/com/android/messaging/ui/contact/AddContactsConfirmationDialog.java +++ b/src/com/android/messaging/ui/contact/AddContactsConfirmationDialog.java @@ -74,9 +74,9 @@ public class AddContactsConfirmationDialog implements DialogInterface.OnClickLis private View createBodyView() { final View view = LayoutInflater.from(mContext).inflate( R.layout.add_contacts_confirmation_dialog_body, null); - final ContactIconView iconView = (ContactIconView) view.findViewById(R.id.contact_icon); + final ContactIconView iconView = view.findViewById(R.id.contact_icon); iconView.setImageResourceUri(mAvatarUri); - final TextView textView = (TextView) view.findViewById(R.id.participant_name); + final TextView textView = view.findViewById(R.id.participant_name); textView.setText(mNormalizedDestination); // Accessibility reason : in case phone numbers are mixed in the display name, // we need to vocalize it for talkback. diff --git a/src/com/android/messaging/ui/contact/ContactListItemView.java b/src/com/android/messaging/ui/contact/ContactListItemView.java index fc8c7f9..eef96b7 100644 --- a/src/com/android/messaging/ui/contact/ContactListItemView.java +++ b/src/com/android/messaging/ui/contact/ContactListItemView.java @@ -64,13 +64,13 @@ public class ContactListItemView extends LinearLayout implements OnClickListener @Override protected void onFinishInflate () { super.onFinishInflate(); - mContactNameTextView = (TextView) findViewById(R.id.contact_name); - mContactDetailsTextView = (TextView) findViewById(R.id.contact_details); - mContactDetailTypeTextView = (TextView) findViewById(R.id.contact_detail_type); - mAlphabetHeaderTextView = (TextView) findViewById(R.id.alphabet_header); - mContactIconView = (ContactIconView) findViewById(R.id.contact_icon); - mContactCheckmarkView = (ImageView) findViewById(R.id.contact_checkmark); - mWorkProfileIcon = (ImageView) findViewById(R.id.work_profile_icon); + mContactNameTextView = findViewById(R.id.contact_name); + mContactDetailsTextView = findViewById(R.id.contact_details); + mContactDetailTypeTextView = findViewById(R.id.contact_detail_type); + mAlphabetHeaderTextView = findViewById(R.id.alphabet_header); + mContactIconView = findViewById(R.id.contact_icon); + mContactCheckmarkView = findViewById(R.id.contact_checkmark); + mWorkProfileIcon = findViewById(R.id.work_profile_icon); } /** diff --git a/src/com/android/messaging/ui/contact/ContactPickerFragment.java b/src/com/android/messaging/ui/contact/ContactPickerFragment.java index 99044b6..66162bf 100644 --- a/src/com/android/messaging/ui/contact/ContactPickerFragment.java +++ b/src/com/android/messaging/ui/contact/ContactPickerFragment.java @@ -172,7 +172,7 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData mFrequentContactsListViewHolder, mAllContactsListViewHolder }; - mCustomHeaderViewPager = (CustomHeaderViewPager) view.findViewById(R.id.contact_pager); + mCustomHeaderViewPager = view.findViewById(R.id.contact_pager); mCustomHeaderViewPager.setViewHolders(viewHolders); mCustomHeaderViewPager.setViewPagerTabHeight(CustomHeaderViewPager.DEFAULT_TAB_STRIP_SIZE); mCustomHeaderViewPager.setBackgroundColor(getResources() @@ -181,7 +181,7 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData // The view pager defaults to the frequent contacts page. mCustomHeaderViewPager.setCurrentItem(0); - mToolbar = (Toolbar) view.findViewById(R.id.toolbar); + mToolbar = view.findViewById(R.id.toolbar); mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_light); mToolbar.setNavigationContentDescription(R.string.back); mToolbar.setNavigationOnClickListener(v -> mHost.onBackButtonPressed()); diff --git a/src/com/android/messaging/ui/conversation/ComposeMessageView.java b/src/com/android/messaging/ui/conversation/ComposeMessageView.java index 2f8df51..9204fa0 100644 --- a/src/com/android/messaging/ui/conversation/ComposeMessageView.java +++ b/src/com/android/messaging/ui/conversation/ComposeMessageView.java @@ -195,8 +195,7 @@ public class ComposeMessageView extends LinearLayout @Override protected void onFinishInflate() { super.onFinishInflate(); - mComposeEditText = (PlainTextEditText) findViewById( - R.id.compose_message_text); + mComposeEditText = findViewById(R.id.compose_message_text); mComposeEditText.setOnEditorActionListener(this); mComposeEditText.addTextChangedListener(this); mComposeEditText.setOnFocusChangeListener((v, hasFocus) -> { @@ -216,7 +215,7 @@ public class ComposeMessageView extends LinearLayout new LengthFilter(MmsConfig.get(ParticipantData.DEFAULT_SELF_SUB_ID) .getMaxTextLimit()) }); - mSelfSendIcon = (SimIconView) findViewById(R.id.self_send_icon); + mSelfSendIcon = findViewById(R.id.self_send_icon); mSelfSendIcon.setOnClickListener(v -> { boolean shown = mInputManager.toggleSimSelector(true /* animate */, getSelfSubscriptionListEntry()); @@ -233,8 +232,7 @@ public class ComposeMessageView extends LinearLayout return true; }); - mComposeSubjectText = (PlainTextEditText) findViewById( - R.id.compose_subject_text); + mComposeSubjectText = findViewById(R.id.compose_subject_text); // We need the listener to change the avatar to the send button when the user starts // typing a subject without a message. mComposeSubjectText.addTextChangedListener(this); @@ -244,7 +242,7 @@ public class ComposeMessageView extends LinearLayout new LengthFilter(MmsConfig.get(ParticipantData.DEFAULT_SELF_SUB_ID) .getMaxSubjectLength())}); - mDeleteSubjectButton = (ImageButton) findViewById(R.id.delete_subject_button); + mDeleteSubjectButton = findViewById(R.id.delete_subject_button); mDeleteSubjectButton.setOnClickListener(clickView -> { hideSubjectEditor(); mComposeSubjectText.setText(null); @@ -253,7 +251,7 @@ public class ComposeMessageView extends LinearLayout mSubjectView = findViewById(R.id.subject_view); - mSendButton = (ImageButton) findViewById(R.id.send_message_button); + mSendButton = findViewById(R.id.send_message_button); mSendButton.setOnClickListener(clickView -> sendMessageInternal(true /* checkMessageSize */)); mSendButton.setOnLongClickListener(arg0 -> { @@ -284,18 +282,17 @@ public class ComposeMessageView extends LinearLayout } }); - mAttachMediaButton = - (ImageButton) findViewById(R.id.attach_media_button); + mAttachMediaButton = findViewById(R.id.attach_media_button); mAttachMediaButton.setOnClickListener(clickView -> { // Showing the media picker is treated as starting to compose the message. mInputManager.showHideMediaPicker(true /* show */, true /* animate */); }); - mAttachmentPreview = (AttachmentPreview) findViewById(R.id.attachment_draft_view); + mAttachmentPreview = findViewById(R.id.attachment_draft_view); mAttachmentPreview.setComposeMessageView(this); - mMessageBodySize = (TextView) findViewById(R.id.message_body_size); - mMmsIndicator = (TextView) findViewById(R.id.mms_indicator); + mMessageBodySize = findViewById(R.id.message_body_size); + mMmsIndicator = findViewById(R.id.mms_indicator); } private void hideAttachmentsWhenShowingSims(final boolean simPickerVisible) { diff --git a/src/com/android/messaging/ui/conversation/ConversationActivity.java b/src/com/android/messaging/ui/conversation/ConversationActivity.java index 635a77a..8f4cdd0 100644 --- a/src/com/android/messaging/ui/conversation/ConversationActivity.java +++ b/src/com/android/messaging/ui/conversation/ConversationActivity.java @@ -71,7 +71,8 @@ public class ConversationActivity extends BugleActionBarActivity // Do our best to restore UI state from saved instance state. if (savedInstanceState != null) { - mUiState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_UI_STATE_KEY); + mUiState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_UI_STATE_KEY, + ConversationActivityUiState.class); } else { if (intent. getBooleanExtra(UIIntents.UI_INTENT_EXTRA_GOTO_CONVERSATION_LIST, false)) { @@ -321,7 +322,7 @@ public class ConversationActivity extends BugleActionBarActivity conversationFragment, ConversationFragment.FRAGMENT_TAG); } final MessageData draftData = intent.getParcelableExtra( - UIIntents.UI_INTENT_EXTRA_DRAFT_DATA); + UIIntents.UI_INTENT_EXTRA_DRAFT_DATA, MessageData.class); if (!needContactPickerFragment) { // Once the user has committed the audience,remove the draft data from the // intent to prevent reuse diff --git a/src/com/android/messaging/ui/conversation/ConversationFragment.java b/src/com/android/messaging/ui/conversation/ConversationFragment.java index 9a6a85a..588dbeb 100644 --- a/src/com/android/messaging/ui/conversation/ConversationFragment.java +++ b/src/com/android/messaging/ui/conversation/ConversationFragment.java @@ -507,7 +507,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.conversation_fragment, container, false); - mRecyclerView = (RecyclerView) view.findViewById(android.R.id.list); + mRecyclerView = view.findViewById(android.R.id.list); final LinearLayoutManager manager = new LinearLayoutManager(getActivity()); manager.setStackFromEnd(true); manager.setReverseLayout(false); @@ -529,16 +529,14 @@ public class ConversationFragment extends Fragment implements ConversationDataLi !data.getIsIncoming() && timeSinceSend < MESSAGE_ANIMATION_MAX_WAIT) { final ConversationMessageBubbleView messageBubble = - (ConversationMessageBubbleView) view - .findViewById(R.id.message_content); + view.findViewById(R.id.message_content); final Rect startRect = UiUtils.getMeasuredBoundsOnScreen(mComposeMessageView); final View composeBubbleView = mComposeMessageView.findViewById( R.id.compose_message_text); final Rect composeBubbleRect = UiUtils.getMeasuredBoundsOnScreen(composeBubbleView); final AttachmentPreview attachmentView = - (AttachmentPreview) mComposeMessageView.findViewById( - R.id.attachment_draft_view); + mComposeMessageView.findViewById(R.id.attachment_draft_view); final Rect attachmentRect = UiUtils.getMeasuredBoundsOnScreen(attachmentView); if (attachmentView.getVisibility() == View.VISIBLE) { startRect.top = attachmentRect.top; @@ -594,7 +592,8 @@ public class ConversationFragment extends Fragment implements ConversationDataLi mRecyclerView.setAdapter(mAdapter); if (savedInstanceState != null) { - mListState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_LIST_VIEW_STATE_KEY); + mListState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_LIST_VIEW_STATE_KEY, + Parcelable.class); } mConversationComposeDivider = view.findViewById(R.id.conversation_compose_divider); @@ -604,8 +603,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi UiUtils.isRtlMode() ? ConversationFastScroller.POSITION_LEFT_SIDE : ConversationFastScroller.POSITION_RIGHT_SIDE); - mComposeMessageView = (ComposeMessageView) - view.findViewById(R.id.message_compose_view_container); + mComposeMessageView = view.findViewById(R.id.message_compose_view_container); // Bind the compose message view to the DraftMessageData mComposeMessageView.bind(DataModel.get().createDraftMessageData( mBinding.getData().getConversationId()), this); @@ -1436,7 +1434,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi @Override public SimSelectorView getSimSelectorView() { - return (SimSelectorView) getView().findViewById(R.id.sim_selector); + return getView().findViewById(R.id.sim_selector); } @Override @@ -1516,8 +1514,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi actionBar.setCustomView(customView); } - final TextView conversationNameView = - (TextView) customView.findViewById(R.id.conversation_title); + final TextView conversationNameView = customView.findViewById(R.id.conversation_title); final String conversationName = getConversationName(); if (!TextUtils.isEmpty(conversationName)) { // RTL : To format conversation title if it happens to be phone numbers. diff --git a/src/com/android/messaging/ui/conversation/ConversationMessageBubbleView.java b/src/com/android/messaging/ui/conversation/ConversationMessageBubbleView.java index 7071ee4..39e5a19 100644 --- a/src/com/android/messaging/ui/conversation/ConversationMessageBubbleView.java +++ b/src/com/android/messaging/ui/conversation/ConversationMessageBubbleView.java @@ -54,7 +54,7 @@ public class ConversationMessageBubbleView extends LinearLayout { @Override protected void onFinishInflate() { super.onFinishInflate(); - mBubbleBackground = (ViewGroup) findViewById(R.id.message_text_and_info); + mBubbleBackground = findViewById(R.id.message_text_and_info); } @Override diff --git a/src/com/android/messaging/ui/conversation/ConversationMessageView.java b/src/com/android/messaging/ui/conversation/ConversationMessageView.java index 03283bd..0916e7f 100644 --- a/src/com/android/messaging/ui/conversation/ConversationMessageView.java +++ b/src/com/android/messaging/ui/conversation/ConversationMessageView.java @@ -124,37 +124,37 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick @Override protected void onFinishInflate() { super.onFinishInflate(); - mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon); + mContactIconView = findViewById(R.id.conversation_icon); mContactIconView.setOnLongClickListener(view -> { ConversationMessageView.this.performLongClick(); return true; }); - mMessageAttachmentsView = (LinearLayout) findViewById(R.id.message_attachments); - mMultiAttachmentView = (MultiAttachmentLayout) findViewById(R.id.multiple_attachments); + mMessageAttachmentsView = findViewById(R.id.message_attachments); + mMultiAttachmentView = findViewById(R.id.multiple_attachments); mMultiAttachmentView.setOnAttachmentClickListener(this); - mMessageImageView = (AsyncImageView) findViewById(R.id.message_image); + mMessageImageView = findViewById(R.id.message_image); mMessageImageView.setOnClickListener(this); mMessageImageView.setOnLongClickListener(this); - mMessageTextView = (TextView) findViewById(R.id.message_text); + mMessageTextView = findViewById(R.id.message_text); mMessageTextView.setOnClickListener(this); IgnoreLinkLongClickHelper.ignoreLinkLongClick(mMessageTextView, this); - mStatusTextView = (TextView) findViewById(R.id.message_status); - mTitleTextView = (TextView) findViewById(R.id.message_title); - mMmsInfoTextView = (TextView) findViewById(R.id.mms_info); - mMessageTitleLayout = (LinearLayout) findViewById(R.id.message_title_layout); - mSenderNameTextView = (TextView) findViewById(R.id.message_sender_name); - mMessageBubble = (ConversationMessageBubbleView) findViewById(R.id.message_content); + mStatusTextView = findViewById(R.id.message_status); + mTitleTextView = findViewById(R.id.message_title); + mMmsInfoTextView = findViewById(R.id.mms_info); + mMessageTitleLayout = findViewById(R.id.message_title_layout); + mSenderNameTextView = findViewById(R.id.message_sender_name); + mMessageBubble = findViewById(R.id.message_content); mSubjectView = findViewById(R.id.subject_container); - mSubjectLabel = (TextView) mSubjectView.findViewById(R.id.subject_label); - mSubjectText = (TextView) mSubjectView.findViewById(R.id.subject_text); + mSubjectLabel = mSubjectView.findViewById(R.id.subject_label); + mSubjectText = mSubjectView.findViewById(R.id.subject_text); mDeliveredBadge = findViewById(R.id.smsDeliveredBadge); - mMessageMetadataView = (ViewGroup) findViewById(R.id.message_metadata); - mMessageTextAndInfoView = (ViewGroup) findViewById(R.id.message_text_and_info); - mSimNameView = (TextView) findViewById(R.id.sim_name); + mMessageMetadataView = findViewById(R.id.message_metadata); + mMessageTextAndInfoView = findViewById(R.id.message_text_and_info); + mSimNameView = findViewById(R.id.sim_name); } @Override @@ -882,8 +882,8 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick private void updateTextAppearance() { int messageColorResId; - int statusColorResId = -1; - int infoColorResId = -1; + int statusColorResId; + int infoColorResId; int timestampColorResId; int subjectLabelColorResId; if (isSelected()) { diff --git a/src/com/android/messaging/ui/conversation/MessageDetailsDialog.java b/src/com/android/messaging/ui/conversation/MessageDetailsDialog.java index 0bd0c13..ada1aa5 100644 --- a/src/com/android/messaging/ui/conversation/MessageDetailsDialog.java +++ b/src/com/android/messaging/ui/conversation/MessageDetailsDialog.java @@ -57,7 +57,7 @@ public class MessageDetailsDialog { private static String getMessageDetails(final Context context, final ConversationMessageData data, final ConversationParticipantsData participants, final ParticipantData self) { - String messageDetails = null; + String messageDetails; if (data.getIsSms()) { messageDetails = getSmsMessageDetails(data, participants, self); } else { diff --git a/src/com/android/messaging/ui/conversation/SimSelectorItemView.java b/src/com/android/messaging/ui/conversation/SimSelectorItemView.java index e5ba0f6..cda9bd7 100644 --- a/src/com/android/messaging/ui/conversation/SimSelectorItemView.java +++ b/src/com/android/messaging/ui/conversation/SimSelectorItemView.java @@ -47,9 +47,9 @@ public class SimSelectorItemView extends LinearLayout { @Override protected void onFinishInflate() { super.onFinishInflate(); - mNameTextView = (TextView) findViewById(R.id.name); - mDetailsTextView = (TextView) findViewById(R.id.details); - mSimIconView = (SimIconView) findViewById(R.id.sim_icon); + mNameTextView = findViewById(R.id.name); + mDetailsTextView = findViewById(R.id.details); + mSimIconView = findViewById(R.id.sim_icon); setOnClickListener(v -> mHost.onSimItemClicked(mData)); } diff --git a/src/com/android/messaging/ui/conversation/SimSelectorView.java b/src/com/android/messaging/ui/conversation/SimSelectorView.java index 8aecb1b..f9df828 100644 --- a/src/com/android/messaging/ui/conversation/SimSelectorView.java +++ b/src/com/android/messaging/ui/conversation/SimSelectorView.java @@ -60,7 +60,7 @@ public class SimSelectorView extends FrameLayout implements SimSelectorItemView. @Override protected void onFinishInflate() { super.onFinishInflate(); - mSimListView = (ListView) findViewById(R.id.sim_list); + mSimListView = findViewById(R.id.sim_list); mSimListView.setAdapter(mAdapter); // Clicking anywhere outside the switcher list should dismiss. diff --git a/src/com/android/messaging/ui/conversationlist/ConversationListFragment.java b/src/com/android/messaging/ui/conversationlist/ConversationListFragment.java index 4a9ceb5..d75a8ac 100644 --- a/src/com/android/messaging/ui/conversationlist/ConversationListFragment.java +++ b/src/com/android/messaging/ui/conversationlist/ConversationListFragment.java @@ -171,8 +171,8 @@ public class ConversationListFragment extends Fragment implements ConversationLi final Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.conversation_list_fragment, container, false); - mRecyclerView = (RecyclerView) rootView.findViewById(android.R.id.list); - mEmptyListMessageView = (ListEmptyView) rootView.findViewById(R.id.no_conversations_view); + mRecyclerView = rootView.findViewById(android.R.id.list); + mEmptyListMessageView = rootView.findViewById(R.id.no_conversations_view); mEmptyListMessageView.setImageHint(R.drawable.ic_oobe_conv_list); // The default behavior for default layout param generation by LinearLayoutManager is to // provide width and height of WRAP_CONTENT, but this is not desirable for @@ -189,7 +189,7 @@ public class ConversationListFragment extends Fragment implements ConversationLi mRecyclerView.setLayoutManager(manager); mRecyclerView.setHasFixedSize(true); mRecyclerView.setAdapter(mAdapter); - mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { + mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { int mCurrentState = AbsListView.OnScrollListener.SCROLL_STATE_IDLE; @Override @@ -216,11 +216,11 @@ public class ConversationListFragment extends Fragment implements ConversationLi mRecyclerView.addOnItemTouchListener(new ConversationListSwipeHelper(mRecyclerView)); if (savedInstanceState != null) { - mListState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_LIST_VIEW_STATE_KEY); + mListState = savedInstanceState.getParcelable(SAVED_INSTANCE_STATE_LIST_VIEW_STATE_KEY, + Parcelable.class); } - mStartNewConversationButton = (ExtendedFloatingActionButton) rootView.findViewById( - R.id.start_new_conversation_button); + mStartNewConversationButton = rootView.findViewById(R.id.start_new_conversation_button); if (mArchiveMode || mForwardMessageMode) { mStartNewConversationButton.setVisibility(View.GONE); } else { diff --git a/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java b/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java index e2f06ec..7d7be8a 100644 --- a/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java +++ b/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java @@ -145,22 +145,21 @@ public class ConversationListItemView extends FrameLayout implements OnClickList @Override protected void onFinishInflate() { super.onFinishInflate(); - mSwipeableContainer = (ViewGroup) findViewById(R.id.swipeableContainer); - mCrossSwipeBackground = (ViewGroup) findViewById(R.id.crossSwipeBackground); - mSwipeableContent = (ViewGroup) findViewById(R.id.swipeableContent); - mConversationNameView = (TextView) findViewById(R.id.conversation_name); - mSnippetTextView = (TextView) findViewById(R.id.conversation_snippet); - mSubjectTextView = (TextView) findViewById(R.id.conversation_subject); - mWorkProfileIconView = (ImageView) findViewById(R.id.work_profile_icon); - mTimestampTextView = (TextView) findViewById(R.id.conversation_timestamp); - mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon); - mContactCheckmarkView = (ImageView) findViewById(R.id.conversation_checkmark); - mFailedStatusIconView = (ImageView) findViewById(R.id.conversation_failed_status_icon); - mCrossSwipeArchiveLeftImageView = (ImageView) findViewById(R.id.crossSwipeArchiveIconLeft); - mCrossSwipeArchiveRightImageView = - (ImageView) findViewById(R.id.crossSwipeArchiveIconRight); - mImagePreviewView = (AsyncImageView) findViewById(R.id.conversation_image_preview); - mAudioAttachmentView = (AudioAttachmentView) findViewById(R.id.audio_attachment_view); + mSwipeableContainer = findViewById(R.id.swipeableContainer); + mCrossSwipeBackground = findViewById(R.id.crossSwipeBackground); + mSwipeableContent = findViewById(R.id.swipeableContent); + mConversationNameView = findViewById(R.id.conversation_name); + mSnippetTextView = findViewById(R.id.conversation_snippet); + mSubjectTextView = findViewById(R.id.conversation_subject); + mWorkProfileIconView = findViewById(R.id.work_profile_icon); + mTimestampTextView = findViewById(R.id.conversation_timestamp); + mContactIconView = findViewById(R.id.conversation_icon); + mContactCheckmarkView = findViewById(R.id.conversation_checkmark); + mFailedStatusIconView = findViewById(R.id.conversation_failed_status_icon); + mCrossSwipeArchiveLeftImageView = findViewById(R.id.crossSwipeArchiveIconLeft); + mCrossSwipeArchiveRightImageView = findViewById(R.id.crossSwipeArchiveIconRight); + mImagePreviewView = findViewById(R.id.conversation_image_preview); + mAudioAttachmentView = findViewById(R.id.audio_attachment_view); mConversationNameView.addOnLayoutChangeListener(this); mSnippetTextView.addOnLayoutChangeListener(this); diff --git a/src/com/android/messaging/ui/conversationlist/ForwardMessageActivity.java b/src/com/android/messaging/ui/conversationlist/ForwardMessageActivity.java index 477d72b..188645e 100644 --- a/src/com/android/messaging/ui/conversationlist/ForwardMessageActivity.java +++ b/src/com/android/messaging/ui/conversationlist/ForwardMessageActivity.java @@ -46,7 +46,8 @@ public class ForwardMessageActivity extends BaseBugleActivity final ConversationListFragment fragment = ConversationListFragment.createForwardMessageConversationListFragment(); getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit(); - mDraftMessage = getIntent().getParcelableExtra(UIIntents.UI_INTENT_EXTRA_DRAFT_DATA); + mDraftMessage = getIntent().getParcelableExtra(UIIntents.UI_INTENT_EXTRA_DRAFT_DATA, + MessageData.class); } @Override diff --git a/src/com/android/messaging/ui/conversationlist/ShareIntentActivity.java b/src/com/android/messaging/ui/conversationlist/ShareIntentActivity.java index f0d0a2d..524d803 100644 --- a/src/com/android/messaging/ui/conversationlist/ShareIntentActivity.java +++ b/src/com/android/messaging/ui/conversationlist/ShareIntentActivity.java @@ -94,7 +94,7 @@ public class ShareIntentActivity extends BaseBugleActivity implements } if (Intent.ACTION_SEND.equals(action)) { - final Uri contentUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); + final Uri contentUri = intent.getParcelableExtra(Intent.EXTRA_STREAM, Uri.class); if (UriUtil.isFileUri(contentUri)) { LogUtil.i( LogUtil.BUGLE_TAG, @@ -134,7 +134,8 @@ public class ShareIntentActivity extends BaseBugleActivity implements } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { final String contentType = intent.getType(); // Handle sharing multiple contents. - final ArrayList uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); + final ArrayList uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM, + Uri.class); if (uris != null && !uris.isEmpty()) { ArrayMap uriMap = new ArrayMap<>(); StringBuffer strBuffer = new StringBuffer(); diff --git a/src/com/android/messaging/ui/conversationlist/ShareIntentFragment.java b/src/com/android/messaging/ui/conversationlist/ShareIntentFragment.java index 62ce642..ef342b7 100644 --- a/src/com/android/messaging/ui/conversationlist/ShareIntentFragment.java +++ b/src/com/android/messaging/ui/conversationlist/ShareIntentFragment.java @@ -71,7 +71,7 @@ public class ShareIntentFragment extends DialogFragment implements ConversationL final Activity activity = getActivity(); final LayoutInflater inflater = activity.getLayoutInflater(); View view = inflater.inflate(R.layout.share_intent_conversation_list_view, null); - mEmptyListMessageView = (ListEmptyView) view.findViewById(R.id.no_conversations_view); + mEmptyListMessageView = view.findViewById(R.id.no_conversations_view); mEmptyListMessageView.setImageHint(R.drawable.ic_oobe_conv_list); // The default behavior for default layout param generation by LinearLayoutManager is to // provide width and height of WRAP_CONTENT, but this is not desirable for @@ -86,7 +86,7 @@ public class ShareIntentFragment extends DialogFragment implements ConversationL }; mListBinding.getData().init(LoaderManager.getInstance(this), mListBinding); mAdapter = new ShareIntentAdapter(activity, null, this); - mRecyclerView = (RecyclerView) view.findViewById(android.R.id.list); + mRecyclerView = view.findViewById(android.R.id.list); mRecyclerView.setLayoutManager(manager); mRecyclerView.setHasFixedSize(true); mRecyclerView.setAdapter(mAdapter); diff --git a/src/com/android/messaging/ui/conversationsettings/PeopleAndOptionsFragment.java b/src/com/android/messaging/ui/conversationsettings/PeopleAndOptionsFragment.java index 38f1a9e..0b75ba2 100644 --- a/src/com/android/messaging/ui/conversationsettings/PeopleAndOptionsFragment.java +++ b/src/com/android/messaging/ui/conversationsettings/PeopleAndOptionsFragment.java @@ -78,7 +78,7 @@ public class PeopleAndOptionsFragment extends Fragment public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.people_and_options_fragment, container, false); - mListView = (ListView) view.findViewById(android.R.id.list); + mListView = view.findViewById(android.R.id.list); mPeopleListAdapter = new PeopleListAdapter(getActivity()); mOptionsListAdapter = new OptionsListAdapter(); final CompositeAdapter compositeAdapter = new CompositeAdapter(getActivity()); @@ -297,14 +297,14 @@ public class PeopleAndOptionsFragment extends Fragment @Override public View getHeaderView(final View convertView, final ViewGroup parentView) { - View view = null; + View view; if (convertView != null && convertView.getId() == R.id.people_and_options_header) { view = convertView; } else { view = LayoutInflater.from(getActivity()).inflate( R.layout.people_and_options_section_header, parentView, false); } - final TextView text = (TextView) view.findViewById(R.id.header_text); + final TextView text = view.findViewById(R.id.header_text); final View divider = view.findViewById(R.id.divider); text.setText(mHeaderResId); divider.setVisibility(mNeedDivider ? View.VISIBLE : View.GONE); diff --git a/src/com/android/messaging/ui/conversationsettings/PeopleOptionsItemView.java b/src/com/android/messaging/ui/conversationsettings/PeopleOptionsItemView.java index 76219ec..5bd3dca 100644 --- a/src/com/android/messaging/ui/conversationsettings/PeopleOptionsItemView.java +++ b/src/com/android/messaging/ui/conversationsettings/PeopleOptionsItemView.java @@ -55,7 +55,7 @@ public class PeopleOptionsItemView extends LinearLayout { @Override protected void onFinishInflate () { super.onFinishInflate(); - mTitle = (TextView) findViewById(R.id.title); + mTitle = findViewById(R.id.title); setOnClickListener(v -> mHostInterface.onOptionsItemViewClicked(mData)); } diff --git a/src/com/android/messaging/ui/mediapicker/AudioRecordView.java b/src/com/android/messaging/ui/mediapicker/AudioRecordView.java index 1d51721..a1f5a14 100644 --- a/src/com/android/messaging/ui/mediapicker/AudioRecordView.java +++ b/src/com/android/messaging/ui/mediapicker/AudioRecordView.java @@ -114,11 +114,11 @@ public class AudioRecordView extends FrameLayout implements @Override protected void onFinishInflate() { super.onFinishInflate(); - mSoundLevels = (SoundLevels) findViewById(R.id.sound_levels); - mRecordButtonVisual = (ImageView) findViewById(R.id.record_button_visual); + mSoundLevels = findViewById(R.id.sound_levels); + mRecordButtonVisual = findViewById(R.id.record_button_visual); mRecordButton = findViewById(R.id.record_button); - mHintTextView = (TextView) findViewById(R.id.hint_text); - mTimerTextView = (PausableChronometer) findViewById(R.id.timer_text); + mHintTextView = findViewById(R.id.hint_text); + mTimerTextView = findViewById(R.id.timer_text); mSoundLevels.setLevelSource(mMediaRecorder.getLevelSource()); mRecordButton.setOnTouchListener((v, event) -> { final int action = event.getActionMasked(); diff --git a/src/com/android/messaging/ui/mediapicker/MediaPicker.java b/src/com/android/messaging/ui/mediapicker/MediaPicker.java index 0448927..1baa4da 100644 --- a/src/com/android/messaging/ui/mediapicker/MediaPicker.java +++ b/src/com/android/messaging/ui/mediapicker/MediaPicker.java @@ -210,7 +210,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat container, false); mMediaPickerPanel.setMediaPicker(this); - mTabStrip = (LinearLayout) mMediaPickerPanel.findViewById(R.id.mediapicker_tabstrip); + mTabStrip = mMediaPickerPanel.findViewById(R.id.mediapicker_tabstrip); mTabStrip.setBackgroundColor(mThemeColor); for (final MediaChooser chooser : mChoosers) { chooser.onCreateTabButton(inflater, mTabStrip); @@ -221,8 +221,8 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat } } - mViewPager = (ViewPager) mMediaPickerPanel.findViewById(R.id.mediapicker_view_pager); - mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { + mViewPager = mMediaPickerPanel.findViewById(R.id.mediapicker_view_pager); + mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled( final int position, diff --git a/src/com/android/messaging/ui/mediapicker/MediaPickerPanel.java b/src/com/android/messaging/ui/mediapicker/MediaPickerPanel.java index e62cb13..8fbd8a2 100644 --- a/src/com/android/messaging/ui/mediapicker/MediaPickerPanel.java +++ b/src/com/android/messaging/ui/mediapicker/MediaPickerPanel.java @@ -96,8 +96,8 @@ public class MediaPickerPanel extends ViewGroup { @Override protected void onFinishInflate() { super.onFinishInflate(); - mTabStrip = (LinearLayout) findViewById(R.id.mediapicker_tabstrip); - mViewPager = (PagingAwareViewPager) findViewById(R.id.mediapicker_view_pager); + mTabStrip = findViewById(R.id.mediapicker_tabstrip); + mViewPager = findViewById(R.id.mediapicker_view_pager); mTouchHandler = new TouchHandler(); setOnTouchListener(mTouchHandler); mViewPager.setOnTouchListener(mTouchHandler); diff --git a/src/com/android/messaging/util/AccessibilityUtil.java b/src/com/android/messaging/util/AccessibilityUtil.java index 5a04aea..39248fc 100644 --- a/src/com/android/messaging/util/AccessibilityUtil.java +++ b/src/com/android/messaging/util/AccessibilityUtil.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2015 The Android Open Source Project - * Copyright (C) 2024 The LineageOS Project + * Copyright (C) 2024-2025 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. @@ -29,8 +29,6 @@ import com.android.messaging.R; import javax.annotation.Nullable; public class AccessibilityUtil { - public static String sContentDescriptionDivider; - public static boolean isTouchExplorationEnabled(final Context context) { final AccessibilityManager accessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); diff --git a/src/com/android/messaging/util/EmailAddress.java b/src/com/android/messaging/util/EmailAddress.java index c1bf584..a8b9e24 100644 --- a/src/com/android/messaging/util/EmailAddress.java +++ b/src/com/android/messaging/util/EmailAddress.java @@ -272,5 +272,5 @@ public final class EmailAddress { protected boolean valid = false; protected String user = null; protected String host = null; - protected boolean allowI18n = false; + protected boolean allowI18n; } diff --git a/src/com/android/messaging/util/ImageUtils.java b/src/com/android/messaging/util/ImageUtils.java index 50e0ea2..7170d0e 100644 --- a/src/com/android/messaging/util/ImageUtils.java +++ b/src/com/android/messaging/util/ImageUtils.java @@ -107,7 +107,6 @@ public class ImageUtils { if (oomCount <= MAX_OOM_COUNT) { Factory.get().reclaimMemory(); } else { - done = true; LogUtil.w(TAG, "Failed to convert bitmap to bytes. Out of Memory."); } throw e; diff --git a/src/com/android/messaging/util/NotificationPlayer.java b/src/com/android/messaging/util/NotificationPlayer.java index 6098ca6..32d38bd 100644 --- a/src/com/android/messaging/util/NotificationPlayer.java +++ b/src/com/android/messaging/util/NotificationPlayer.java @@ -186,7 +186,7 @@ public class NotificationPlayer implements OnCompletionListener { @Override public void run() { while (true) { - Command cmd = null; + Command cmd; synchronized (mCmdQueue) { if (mDebug) { @@ -327,31 +327,6 @@ public class NotificationPlayer implements OnCompletionListener { } } - /** - * We want to hold a wake lock while we do the prepare and play. The stop probably is - * optional, but it won't hurt to have it too. The problem is that if you start a sound - * while you're holding a wake lock (e.g. an alarm starting a notification), you want the - * sound to play, but if the CPU turns off before mThread gets to work, it won't. The - * simplest way to deal with this is to make it so there is a wake lock held while the - * thread is starting or running. You're going to need the WAKE_LOCK permission if you're - * going to call this. - * - * This must be called before the first time play is called. - * - * @hide - */ - public void setUsesWakeLock() { - if (mWakeLock != null || mThread != null) { - // if either of these has happened, we've already played something. - // and our releases will be out of sync. - throw new RuntimeException("assertion failed mWakeLock=" + mWakeLock - + " mThread=" + mThread); - } - final PowerManager pm = (PowerManager) Factory.get().getApplicationContext() - .getSystemService(Context.POWER_SERVICE); - mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mTag); - } - private void acquireWakeLock() { if (mWakeLock != null) { mWakeLock.acquire(); diff --git a/src/com/android/messaging/util/NotificationsUtil.java b/src/com/android/messaging/util/NotificationsUtil.java index ef0451a..ebb1d82 100644 --- a/src/com/android/messaging/util/NotificationsUtil.java +++ b/src/com/android/messaging/util/NotificationsUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 The LineageOS Project + * Copyright (C) 2019-2025 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. @@ -72,9 +72,4 @@ public final class NotificationsUtil { NotificationManager manager = context.getSystemService(NotificationManager.class); return manager.getNotificationChannel(id); } - - public static NotificationChannelGroup getNotificationChannelGroup(Context context, String id) { - NotificationManager manager = context.getSystemService(NotificationManager.class); - return manager.getNotificationChannelGroup(id); - } } diff --git a/src/com/android/messaging/util/TextUtil.java b/src/com/android/messaging/util/TextUtil.java index f715551..cf3c155 100644 --- a/src/com/android/messaging/util/TextUtil.java +++ b/src/com/android/messaging/util/TextUtil.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 The Android Open Source Project + * Copyright (C) 2025 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. @@ -54,20 +55,4 @@ public class TextUtil { } return normalizedDigits.toString(); } - - /** - * Appends text to the stringBuilder. - * If stringBuilder already has content, separator is prepended to create a separator between - * entries. - * @param stringBuilder The stringBuilder to add to - * @param text The text to append - * @param separator The separator to add if there is already text, typically "," or "\n" - */ - public static void appendWithSeparator(final StringBuilder stringBuilder, final String text, - final String separator) { - if (stringBuilder.length() > 0) { - stringBuilder.append(separator); - } - stringBuilder.append(text); - } } diff --git a/src/com/android/messaging/util/TintDrawableWrapper.java b/src/com/android/messaging/util/TintDrawableWrapper.java deleted file mode 100644 index b426f8c..0000000 --- a/src/com/android/messaging/util/TintDrawableWrapper.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.messaging.util; - -import android.content.res.ColorStateList; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; -import androidx.appcompat.graphics.drawable.DrawableWrapperCompat; - -/* - * This is directly copied from v7/appcompat/src/androidx.appcompat.internal/widget/TintManager.java - */ - -/** - * A {@link DrawableWrapperCompat} which updates it's color filter using a {@link ColorStateList}. - */ -class TintDrawableWrapper extends DrawableWrapperCompat { - private final ColorStateList mTintStateList; - private final PorterDuff.Mode mTintMode; - private int mCurrentColor; - public TintDrawableWrapper(Drawable drawable, ColorStateList tintStateList) { - this(drawable, tintStateList, PorterDuff.Mode.SRC_IN); - } - public TintDrawableWrapper(Drawable drawable, ColorStateList tintStateList, - PorterDuff.Mode tintMode) { - super(drawable); - mTintStateList = tintStateList; - mTintMode = tintMode; - } - @Override - public boolean isStateful() { - return (mTintStateList != null && mTintStateList.isStateful()) || super.isStateful(); - } - @Override - public boolean setState(int[] stateSet) { - boolean handled = super.setState(stateSet); - handled = updateTint(stateSet) || handled; - return handled; - } - private boolean updateTint(int[] state) { - if (mTintStateList != null) { - final int color = mTintStateList.getColorForState(state, mCurrentColor); - if (color != mCurrentColor) { - if (color != Color.TRANSPARENT) { - setColorFilter(color, mTintMode); - } else { - clearColorFilter(); - } - mCurrentColor = color; - return true; - } - } - return false; - } -} diff --git a/src/com/android/messaging/util/UriUtil.java b/src/com/android/messaging/util/UriUtil.java index 0bb99fa..1c6143c 100644 --- a/src/com/android/messaging/util/UriUtil.java +++ b/src/com/android/messaging/util/UriUtil.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2015 The Android Open Source Project - * Copyright (C) 2024 The LineageOS Project + * Copyright (C) 2024-2025 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. @@ -18,7 +18,6 @@ package com.android.messaging.util; import android.content.ContentResolver; import android.content.Context; -import android.content.res.AssetFileDescriptor; import android.media.MediaMetadataRetriever; import android.net.Uri; import android.os.ParcelFileDescriptor; @@ -347,32 +346,6 @@ public class UriUtil { return TextUtil.replaceUnicodeDigits(parts[0]).replace(';', ','); } - /** - * Return the length of the file to which contentUri refers - * - * @param contentUri URI for the file of which we want the length - * @return Length of the file or AssetFileDescriptor.UNKNOWN_LENGTH - */ - public static long getUriContentLength(final Uri contentUri) { - final Context context = Factory.get().getApplicationContext(); - AssetFileDescriptor afd = null; - try { - afd = context.getContentResolver().openAssetFileDescriptor(contentUri, "r"); - return afd.getLength(); - } catch (final FileNotFoundException e) { - LogUtil.w(LogUtil.BUGLE_TAG, "Failed to query length of " + contentUri); - } finally { - if (afd != null) { - try { - afd.close(); - } catch (final IOException e) { - LogUtil.w(LogUtil.BUGLE_TAG, "Failed to close afd for " + contentUri); - } - } - } - return AssetFileDescriptor.UNKNOWN_LENGTH; - } - /** @return string representation of URI or null if URI was null */ public static String stringFromUri(final Uri uri) { return uri == null ? null : uri.toString(); diff --git a/src/com/android/messaging/util/VersionUtil.java b/src/com/android/messaging/util/VersionUtil.java index b87aa55..7b3ee34 100644 --- a/src/com/android/messaging/util/VersionUtil.java +++ b/src/com/android/messaging/util/VersionUtil.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 The Android Open Source Project + * Copyright (C) 2025 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,7 +27,6 @@ public final class VersionUtil { private static final Object sLock = new Object(); private static VersionUtil sInstance; private final String mSimpleVersionName; - private final int mVersionCode; public static VersionUtil getInstance(final Context context) { synchronized (sLock) { @@ -47,7 +47,6 @@ public final class VersionUtil { Assert.fail("couldn't get package info " + exception); versionCode = -1; } - mVersionCode = versionCode; final int majorBuildNumber = versionCode / 1000; // Use US locale to format version number so that other language characters don't // show up in version string. @@ -57,10 +56,6 @@ public final class VersionUtil { majorBuildNumber % 1000); } - public int getVersionCode() { - return mVersionCode; - } - public String getSimpleName() { return mSimpleVersionName; } diff --git a/src/com/android/messaging/util/WakeLockHelper.java b/src/com/android/messaging/util/WakeLockHelper.java deleted file mode 100644 index cd5fd34..0000000 --- a/src/com/android/messaging/util/WakeLockHelper.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.messaging.util; - -import android.content.Context; -import android.content.Intent; -import android.os.Debug; -import android.os.PowerManager; -import android.os.Process; - -/** - * Helper class used to manage wakelock state - */ -public class WakeLockHelper { - private static final String TAG = LogUtil.BUGLE_DATAMODEL_TAG; - private static final boolean VERBOSE = false; - - public static final String EXTRA_CALLING_PID = "pid"; - - private final Object mLock = new Object(); - private final String mWakeLockId; - private final int mMyPid; - - private PowerManager.WakeLock mWakeLock; - - public WakeLockHelper(final String wakeLockId) { - mWakeLockId = wakeLockId; - mMyPid = Process.myPid(); - } - - /** - * Acquire the wakelock - */ - public void acquire(final Context context, final Intent intent, final int opcode) { - synchronized (mLock) { - if (mWakeLock == null) { - if (VERBOSE) { - LogUtil.v(TAG, "initializing wakelock"); - } - final PowerManager pm = (PowerManager) - context.getSystemService(Context.POWER_SERVICE); - mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, mWakeLockId); - } - } - if (VERBOSE) { - LogUtil.v(TAG, "acquiring " + mWakeLockId + " for opcode " + opcode); - } - mWakeLock.acquire(); - intent.putExtra(EXTRA_CALLING_PID, mMyPid); - } - - /** - * Check if wakelock held by this process - */ - public boolean isHeld(final Intent intent) { - final boolean respectWakeLock = (mMyPid == intent.getIntExtra(EXTRA_CALLING_PID, -1)); - return (respectWakeLock && mWakeLock.isHeld()); - } - - /** - * Ensure that wakelock is held by this process - */ - public boolean ensure(final Intent intent, final int opcode) { - final boolean respectWakeLock = (mMyPid == intent.getIntExtra(EXTRA_CALLING_PID, -1)); - if (VERBOSE) { - LogUtil.v(TAG, "WakeLockHelper.ensure Intent " + intent + " " - + intent.getAction() + " opcode: " + opcode - + " respectWakeLock " + respectWakeLock); - } - - if (respectWakeLock) { - final boolean isHeld = (respectWakeLock && isHeld(intent)); - if (!isHeld) { - LogUtil.e(TAG, "WakeLockHelper.ensure called " + intent + " " + intent.getAction() - + " opcode: " + opcode + " sWakeLock: " + mWakeLock + " isHeld: " - + ((mWakeLock == null) ? "(null)" : mWakeLock.isHeld())); - if (!Debug.isDebuggerConnected()) { - Assert.fail("WakeLock dropped prior to service starting"); - } - } - return true; - } - return false; - } - - /** - * Release wakelock (if it is held by this process) - */ - public void release(final Intent intent, final int opcode) { - final boolean respectWakeLock = (mMyPid == intent.getIntExtra(EXTRA_CALLING_PID, -1)); - if (respectWakeLock) { - try { - mWakeLock.release(); - } catch (final RuntimeException ex) { - LogUtil.e(TAG, "KeepAliveService.onHandleIntent exit crash " + intent + " " - + intent.getAction() + " opcode: " + opcode + " sWakeLock: " + mWakeLock - + " isHeld: " + ((mWakeLock == null) ? "(null)" : mWakeLock.isHeld())); - if (!Debug.isDebuggerConnected()) { - Assert.fail("WakeLock no longer held at end of handler"); - } - } - } - } -} diff --git a/src/com/android/messaging/util/exif/ExifInterface.java b/src/com/android/messaging/util/exif/ExifInterface.java index ccd1d69..4d563fc 100644 --- a/src/com/android/messaging/util/exif/ExifInterface.java +++ b/src/com/android/messaging/util/exif/ExifInterface.java @@ -735,7 +735,7 @@ public class ExifInterface { if (inStream == null) { throw new IllegalArgumentException(NULL_ARGUMENT_STRING); } - ExifData d = null; + ExifData d; try { d = new ExifReader(this).read(inStream); } catch (ExifInvalidFormatException e) { @@ -1000,7 +1000,7 @@ public class ExifInterface { is = new BufferedInputStream(new FileInputStream(temp)); // Parse beginning of APP1 in exif to find size of exif header. - ExifParser parser = null; + ExifParser parser; try { parser = ExifParser.parse(is, this); } catch (ExifInvalidFormatException e) { @@ -1048,7 +1048,7 @@ public class ExifInterface { * changes are made to the ByteBuffer. */ public boolean rewriteExif(ByteBuffer buf, Collection tags) throws IOException { - ExifModifier mod = null; + ExifModifier mod; try { mod = new ExifModifier(buf, this); for (ExifTag t : tags) { @@ -1079,7 +1079,7 @@ public class ExifInterface { ExifData tempData = mData; mData = new ExifData(DEFAULT_BYTE_ORDER); FileInputStream is = null; - ByteArrayOutputStream bytes = null; + ByteArrayOutputStream bytes; try { is = new FileInputStream(filename); bytes = new ByteArrayOutputStream(); diff --git a/src/com/android/messaging/util/exif/ExifParser.java b/src/com/android/messaging/util/exif/ExifParser.java index 1c242f8..3f922b7 100644 --- a/src/com/android/messaging/util/exif/ExifParser.java +++ b/src/com/android/messaging/util/exif/ExifParser.java @@ -157,7 +157,7 @@ public class ExifParser { private ExifTag mStripSizeTag; private ExifTag mJpegSizeTag; private boolean mNeedToParseOffsetsInCurrentIfd; - private boolean mContainExifData = false; + private boolean mContainExifData; private int mApp1End; private int mOffsetToApp1EndFromSOF = 0; private byte[] mDataAboveIfd0; @@ -759,8 +759,8 @@ public class ExifParser { // Some invalid formatted image contains multiple APP1, // try to find the one with Exif data. if (marker == JpegHeader.APP1) { - int header = 0; - short headerTail = 0; + int header; + short headerTail; if (length >= 8) { header = dataStream.readInt(); headerTail = dataStream.readShort(); diff --git a/src/com/android/messaging/util/exif/ExifReader.java b/src/com/android/messaging/util/exif/ExifReader.java index 0b23ee0..3215f02 100644 --- a/src/com/android/messaging/util/exif/ExifReader.java +++ b/src/com/android/messaging/util/exif/ExifReader.java @@ -44,7 +44,7 @@ class ExifReader { IOException { ExifParser parser = ExifParser.parse(inputStream, mInterface); ExifData exifData = new ExifData(parser.getByteOrder()); - ExifTag tag = null; + ExifTag tag; int event = parser.next(); while (event != ExifParser.EVENT_END) { diff --git a/src/com/android/messaging/widget/WidgetConversationService.java b/src/com/android/messaging/widget/WidgetConversationService.java index f3226e2..2d9b6b4 100644 --- a/src/com/android/messaging/widget/WidgetConversationService.java +++ b/src/com/android/messaging/widget/WidgetConversationService.java @@ -264,7 +264,7 @@ public class WidgetConversationService extends RemoteViewsService { int titleResId = -1; int statusResId = -1; boolean showInRed = false; - String statusText = null; + String statusText; switch(message.getStatus()) { case MessageData.BUGLE_STATUS_INCOMING_AUTO_DOWNLOADING: case MessageData.BUGLE_STATUS_INCOMING_MANUAL_DOWNLOADING: @@ -327,7 +327,7 @@ public class WidgetConversationService extends RemoteViewsService { case MessageData.BUGLE_STATUS_INCOMING_COMPLETE: default: if (!message.getCanClusterWithNextMessage()) { - statusText = Dates.getWidgetTimeString(message.getReceivedTimeStamp(), + Dates.getWidgetTimeString(message.getReceivedTimeStamp(), false /*abbreviated*/).toString(); } break;