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
This commit is contained in:
Michael W
2025-01-01 13:54:07 +01:00
parent 47f5533a73
commit b2f5e3190e
110 changed files with 289 additions and 561 deletions

View File

@@ -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) {

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -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, () -> {

View File

@@ -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;

View File

@@ -22,7 +22,7 @@ public class GenericPdu {
/**
* The headers of pdu.
*/
PduHeaders mPduHeaders = null;
PduHeaders mPduHeaders;
/**
* Constructor.

View File

@@ -21,7 +21,7 @@ package android.support.v7.mms.pdu;
import java.util.Vector;
public class PduBody {
private Vector<PduPart> mParts = null;
private Vector<PduPart> mParts;
/**
* Constructor.

View File

@@ -323,7 +323,7 @@ public class PduHeaders {
/**
* The map contains the value of all headers.
*/
private SparseArray<Object> mHeaderMap = null;
private SparseArray<Object> mHeaderMap;
/**
* Constructor of PduHeaders.

View File

@@ -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 ) {

View File

@@ -106,7 +106,7 @@ public class PduPart {
/**
* Header of part.
*/
private SparseArray<Object> mPartHeader = null;
private SparseArray<Object> mPartHeader;
/**
* Data uri.

View File

@@ -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);

View File

@@ -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<NotificationLineInfo> lineInfos = convInfo.mLineInfos;
final int messageCount = lineInfos.size();

View File

@@ -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;
}

View File

@@ -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: " +

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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");

View File

@@ -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);

View File

@@ -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

View File

@@ -97,7 +97,8 @@ public class GetOrCreateConversationAction extends Action implements Parcelable
// First find the thread id for this list of participants.
final ArrayList<ParticipantData> participants =
actionParameters.getParcelableArrayList(KEY_PARTICIPANTS_LIST);
actionParameters.getParcelableArrayList(KEY_PARTICIPANTS_LIST,
ParticipantData.class);
BugleDatabaseOperations.sanitizeConversationParticipants(participants);
final ArrayList<String> recipients =
BugleDatabaseOperations.getRecipientsFromConversationParticipants(participants);

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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

View File

@@ -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<SmsMessage> smsToAdd =
response.getParcelableArrayList(BUNDLE_KEY_SMS_MESSAGES);
response.getParcelableArrayList(BUNDLE_KEY_SMS_MESSAGES, SmsMessage.class);
final ArrayList<MmsMessage> mmsToAdd =
response.getParcelableArrayList(BUNDLE_KEY_MMS_MESSAGES);
response.getParcelableArrayList(BUNDLE_KEY_MMS_MESSAGES, MmsMessage.class);
final ArrayList<LocalDatabaseMessage> 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();

View File

@@ -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

View File

@@ -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);

View File

@@ -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));
}
}

View File

@@ -220,7 +220,6 @@ public class DecodedImageResource extends ImageResource {
} finally {
if (scaledBitmap != null && scaledBitmap != getBitmap()) {
scaledBitmap.recycle();
scaledBitmap = null;
}
releaseLock();
release();

View File

@@ -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.

View File

@@ -157,7 +157,7 @@ public class MediaResourceManager {
final MediaRequest<T> mediaRequest)
throws Exception {
final List<MediaRequest<T>> chainedRequests = new ArrayList<>();
T loadedResource = null;
T loadedResource;
// Try fetching from cache first.
final T cachedResource = loadMediaFromCache(mediaRequest);
if (cachedResource != null) {

View File

@@ -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()));

View File

@@ -48,7 +48,7 @@ public class VideoThumbnailRequest extends ImageRequest<UriImageRequestDescripto
@Override
protected Bitmap getBitmapForResource() throws IOException {
Bitmap bitmap = null;
Bitmap bitmap;
// Get a thumbnail through MediaMetadataRetriever to get a representative frame at any time
// position instead.
final MediaMetadataRetrieverWrapper retriever = new MediaMetadataRetrieverWrapper();

View File

@@ -96,22 +96,22 @@ public class PduComposer {
/**
* The output message.
*/
protected ByteArrayOutputStream mMessage = null;
protected ByteArrayOutputStream mMessage;
/**
* The PDU.
*/
private GenericPdu mPdu = null;
private GenericPdu mPdu;
/**
* Current visiting position of the mMessage.
*/
protected int mPosition = 0;
protected int mPosition;
/**
* Message compose buffer stack.
*/
private BufferStack mStack = null;
private BufferStack mStack;
/**
* Content resolver.
@@ -121,12 +121,12 @@ public class PduComposer {
/**
* Header of this pdu.
*/
private PduHeaders mPduHeader = null;
private PduHeaders mPduHeader;
/**
* Map of all content type
*/
private static SimpleArrayMap<String, Integer> mContentTypeMap = null;
private static SimpleArrayMap<String, Integer> 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;

View File

@@ -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

View File

@@ -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 {

View File

@@ -188,7 +188,7 @@ public final class PduCache extends AbstractCache<Uri, PduCacheEntry> {
*/
private Uri normalizeKey(Uri uri) {
int match = URI_MATCHER.match(uri);
Uri normalizedKey = null;
Uri normalizedKey;
switch (match) {
case MMS_ALL_ID:

View File

@@ -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();

View File

@@ -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*/);

View File

@@ -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()));
}
}

View File

@@ -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) {

View File

@@ -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

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -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()));
}

View File

@@ -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));

View File

@@ -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)) {

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -108,7 +108,7 @@ public class FixedViewPagerAdapter<T extends PagerViewHolder> 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 {

View File

@@ -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);
}
}

View File

@@ -76,7 +76,6 @@ public class LineWrapLayout extends ViewGroup {
currLineHeight = 0;
x = startPadding;
currLineWidth = 0;
startMargin = 0;
}
x += childMeasuredWidth;

View File

@@ -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) {

View File

@@ -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();
}
}

View File

@@ -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()));

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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);

View File

@@ -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().

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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(

View File

@@ -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(

View File

@@ -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)) {

View File

@@ -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);

View File

@@ -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,

View File

@@ -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);
}
}

View File

@@ -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.

View File

@@ -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);
}
/**

View File

@@ -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());

View File

@@ -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) {

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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()) {

View File

@@ -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 {

View File

@@ -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));
}

View File

@@ -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.

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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

View File

@@ -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<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
final ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM,
Uri.class);
if (uris != null && !uris.isEmpty()) {
ArrayMap<Uri, String> uriMap = new ArrayMap<>();
StringBuffer strBuffer = new StringBuffer();

View File

@@ -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);

View File

@@ -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);

View File

@@ -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));
}

View File

@@ -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();

View File

@@ -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,

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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();

Some files were not shown because too many files have changed in this diff Show More