Messaging: Let there be lambdas

Change-Id: Iee1fc46c92ea9159abb10d92d34baee937bdee0c
This commit is contained in:
Michael W
2024-12-26 14:55:12 +01:00
parent c1b4aa4dfe
commit d43b6ff1c4
84 changed files with 991 additions and 1697 deletions
@@ -17,7 +17,6 @@
package android.support.v7.mms; package android.support.v7.mms;
import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.XmlResourceParser; import android.content.res.XmlResourceParser;
@@ -403,9 +402,7 @@ class DefaultApnSettingsLoader implements ApnSettingsLoader {
XmlResourceParser xml = null; XmlResourceParser xml = null;
try { try {
xml = mContext.getResources().getXml(R.xml.apns); xml = mContext.getResources().getXml(R.xml.apns);
new ApnsXmlParser(xml, new ApnsXmlParser.ApnProcessor() { new ApnsXmlParser(xml, apnValues -> {
@Override
public void process(ContentValues apnValues) {
final String mcc = trimWithNullCheck(apnValues.getAsString(APN_MCC)); final String mcc = trimWithNullCheck(apnValues.getAsString(APN_MCC));
final String mnc = trimWithNullCheck(apnValues.getAsString(APN_MNC)); final String mnc = trimWithNullCheck(apnValues.getAsString(APN_MNC));
final String apn = trimWithNullCheck(apnValues.getAsString(APN_APN)); final String apn = trimWithNullCheck(apnValues.getAsString(APN_APN));
@@ -425,7 +422,6 @@ class DefaultApnSettingsLoader implements ApnSettingsLoader {
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
// Ignore // Ignore
} }
}
}).parse(); }).parse();
} catch (final Resources.NotFoundException e) { } catch (final Resources.NotFoundException e) {
Log.w(MmsService.TAG, "Can not get apns.xml " + e); Log.w(MmsService.TAG, "Can not get apns.xml " + e);
@@ -95,9 +95,7 @@ class DefaultCarrierConfigValuesLoader implements CarrierConfigValuesLoader {
XmlResourceParser xml = null; XmlResourceParser xml = null;
try { try {
xml = subContext.getResources().getXml(R.xml.mms_config); xml = subContext.getResources().getXml(R.xml.mms_config);
new CarrierConfigXmlParser(xml, new CarrierConfigXmlParser.KeyValueProcessor() { new CarrierConfigXmlParser(xml, (type, key, value) -> {
@Override
public void process(String type, String key, String value) {
try { try {
if (KEY_TYPE_INT.equals(type)) { if (KEY_TYPE_INT.equals(type)) {
values.putInt(key, Integer.parseInt(value)); values.putInt(key, Integer.parseInt(value));
@@ -110,7 +108,6 @@ class DefaultCarrierConfigValuesLoader implements CarrierConfigValuesLoader {
Log.w(MmsService.TAG, "Load carrier value from resources: " Log.w(MmsService.TAG, "Load carrier value from resources: "
+ "invalid " + key + "," + value + "," + type); + "invalid " + key + "," + value + "," + type);
} }
}
}).parse(); }).parse();
} catch (final Resources.NotFoundException e) { } catch (final Resources.NotFoundException e) {
Log.w(MmsService.TAG, "Can not get mms_config.xml"); Log.w(MmsService.TAG, "Can not get mms_config.xml");
@@ -82,8 +82,7 @@ class DownloadRequest extends MmsRequest {
if (contentUri == null || pdu == null) { if (contentUri == null || pdu == null) {
return false; return false;
} }
final Callable<Boolean> copyDownloadedPduToOutput = new Callable<Boolean>() { final Callable<Boolean> copyDownloadedPduToOutput = () -> {
public Boolean call() {
ParcelFileDescriptor.AutoCloseOutputStream outStream = null; ParcelFileDescriptor.AutoCloseOutputStream outStream = null;
try { try {
final ContentResolver cr = context.getContentResolver(); final ContentResolver cr = context.getContentResolver();
@@ -103,7 +102,6 @@ class DownloadRequest extends MmsRequest {
} }
} }
} }
}
}; };
final Future<Boolean> pendingResult = final Future<Boolean> pendingResult =
mPduTransferExecutor.submit(copyDownloadedPduToOutput); mPduTransferExecutor.submit(copyDownloadedPduToOutput);
+2 -10
View File
@@ -251,12 +251,7 @@ public class MmsService extends Service {
// Handler for scheduling service stop // Handler for scheduling service stop
private final Handler mHandler = new Handler(); private final Handler mHandler = new Handler();
// Service stop task // Service stop task
private final Runnable mServiceStopRunnable = new Runnable() { private final Runnable mServiceStopRunnable = this::tryStopService;
@Override
public void run() {
tryStopService();
}
};
/** /**
* Start the service with a request * Start the service with a request
@@ -325,9 +320,7 @@ public class MmsService extends Service {
final MmsRequest request = intent.getParcelableExtra(EXTRA_REQUEST); final MmsRequest request = intent.getParcelableExtra(EXTRA_REQUEST);
if (request != null) { if (request != null) {
try { try {
retainService(request, new Runnable() { retainService(request, () -> {
@Override
public void run() {
try { try {
request.execute( request.execute(
MmsService.this, MmsService.this,
@@ -343,7 +336,6 @@ public class MmsService extends Service {
} }
releaseService(); releaseService();
} }
}
}); });
scheduled = true; scheduled = true;
} catch (RejectedExecutionException e) { } catch (RejectedExecutionException e) {
+1 -3
View File
@@ -101,8 +101,7 @@ class SendRequest extends MmsRequest {
if (contentUri == null) { if (contentUri == null) {
return null; return null;
} }
final Callable<byte[]> copyPduToArray = new Callable<byte[]>() { final Callable<byte[]> copyPduToArray = () -> {
public byte[] call() {
ParcelFileDescriptor.AutoCloseInputStream inStream = null; ParcelFileDescriptor.AutoCloseInputStream inStream = null;
try { try {
final ContentResolver cr = context.getContentResolver(); final ContentResolver cr = context.getContentResolver();
@@ -135,7 +134,6 @@ class SendRequest extends MmsRequest {
} }
} }
} }
}
}; };
final Future<byte[]> pendingResult = mPduTransferExecutor.submit(copyPduToArray); final Future<byte[]> pendingResult = mPduTransferExecutor.submit(copyPduToArray);
try { try {
@@ -127,14 +127,10 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
MmsManager.setForceLegacyMms(!bugleGservices.getBoolean( MmsManager.setForceLegacyMms(!bugleGservices.getBoolean(
BugleGservicesKeys.USE_MMS_API_IF_PRESENT, BugleGservicesKeys.USE_MMS_API_IF_PRESENT,
BugleGservicesKeys.USE_MMS_API_IF_PRESENT_DEFAULT)); BugleGservicesKeys.USE_MMS_API_IF_PRESENT_DEFAULT));
bugleGservices.registerForChanges(new Runnable() { bugleGservices.registerForChanges(() -> MmsManager.setForceLegacyMms(
@Override !bugleGservices.getBoolean(
public void run() {
MmsManager.setForceLegacyMms(!bugleGservices.getBoolean(
BugleGservicesKeys.USE_MMS_API_IF_PRESENT, BugleGservicesKeys.USE_MMS_API_IF_PRESENT,
BugleGservicesKeys.USE_MMS_API_IF_PRESENT_DEFAULT)); BugleGservicesKeys.USE_MMS_API_IF_PRESENT_DEFAULT)));
}
});
} }
public static void updateAppConfig(final Context context) { public static void updateAppConfig(final Context context) {
@@ -168,13 +164,7 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
LogUtil.e(TAG, "Uncaught exception in background thread " + thread, ex); LogUtil.e(TAG, "Uncaught exception in background thread " + thread, ex);
final Handler handler = new Handler(getMainLooper()); final Handler handler = new Handler(getMainLooper());
handler.post(new Runnable() { handler.post(() -> sSystemUncaughtExceptionHandler.uncaughtException(thread, ex));
@Override
public void run() {
sSystemUncaughtExceptionHandler.uncaughtException(thread, ex);
}
});
} else { } else {
sSystemUncaughtExceptionHandler.uncaughtException(thread, ex); sSystemUncaughtExceptionHandler.uncaughtException(thread, ex);
} }
@@ -192,16 +182,12 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
final File file = DebugUtils.getDebugFile("startup.trace", true); final File file = DebugUtils.getDebugFile("startup.trace", true);
if (file != null) { if (file != null) {
android.os.Debug.startMethodTracing(file.getAbsolutePath(), 160 * 1024 * 1024); android.os.Debug.startMethodTracing(file.getAbsolutePath(), 160 * 1024 * 1024);
new Handler(Looper.getMainLooper()).postDelayed( new Handler(Looper.getMainLooper()).postDelayed(() -> {
new Runnable() {
@Override
public void run() {
android.os.Debug.stopMethodTracing(); android.os.Debug.stopMethodTracing();
// Allow world to see trace file // Allow world to see trace file
DebugUtils.ensureReadable(file); DebugUtils.ensureReadable(file);
LogUtil.d(LogUtil.PROFILE_TAG, "Tracing complete - " LogUtil.d(LogUtil.PROFILE_TAG, "Tracing complete - "
+ file.getAbsolutePath()); + file.getAbsolutePath());
}
}, 30000); }, 30000);
} }
} }
@@ -219,13 +205,8 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
// Perform upgrade on application-wide prefs. // Perform upgrade on application-wide prefs.
factory.getApplicationPrefs().onUpgrade(existingVersion, targetVersion); factory.getApplicationPrefs().onUpgrade(existingVersion, targetVersion);
// Perform upgrade on each subscription's prefs. // Perform upgrade on each subscription's prefs.
PhoneUtils.forEachActiveSubscription(new PhoneUtils.SubscriptionRunnable() { PhoneUtils.forEachActiveSubscription(subId -> factory.getSubscriptionPrefs(subId)
@Override .onUpgrade(existingVersion, targetVersion));
public void runForSubscription(final int subId) {
factory.getSubscriptionPrefs(subId)
.onUpgrade(existingVersion, targetVersion);
}
});
factory.getApplicationPrefs().putInt(BuglePrefsKeys.SHARED_PREFERENCES_VERSION, factory.getApplicationPrefs().putInt(BuglePrefsKeys.SHARED_PREFERENCES_VERSION,
targetVersion); targetVersion);
} catch (final Exception ex) { } catch (final Exception ex) {
+3 -5
View File
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -117,13 +118,10 @@ class FactoryImpl extends Factory {
mApplication.initializeSync(this); mApplication.initializeSync(this);
final Thread asyncInitialization = new Thread() { final Thread asyncInitialization = new Thread(() -> {
@Override
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
mApplication.initializeAsync(FactoryImpl.this); mApplication.initializeAsync(FactoryImpl.this);
} });
};
asyncInitialization.start(); asyncInitialization.start();
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1085,12 +1086,7 @@ public class BugleNotifications {
OBSERVABLE_CONVERSATION_NOTIFICATION_VOLUME); OBSERVABLE_CONVERSATION_NOTIFICATION_VOLUME);
// Stop the sound after five seconds to handle continuous ringtones // Stop the sound after five seconds to handle continuous ringtones
ThreadUtil.getMainThreadHandler().postDelayed(new Runnable() { ThreadUtil.getMainThreadHandler().postDelayed(player::stop, 5000);
@Override
public void run() {
player.stop();
}
}, 5000);
} }
public static boolean isWearCompanionAppInstalled() { public static boolean isWearCompanionAppInstalled() {
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -235,9 +236,7 @@ public class DataModelImpl extends DataModel {
} }
private void createConnectivityUtilForEachActiveSubscription() { private void createConnectivityUtilForEachActiveSubscription() {
PhoneUtils.forEachActiveSubscription(new PhoneUtils.SubscriptionRunnable() { PhoneUtils.forEachActiveSubscription(subId -> {
@Override
public void runForSubscription(int subId) {
// Create the ConnectivityUtil instance for given subId if absent. // Create the ConnectivityUtil instance for given subId if absent.
if (subId <= ParticipantData.DEFAULT_SELF_SUB_ID) { if (subId <= ParticipantData.DEFAULT_SELF_SUB_ID) {
subId = PhoneUtils.getDefault().getDefaultSmsSubscriptionId(); subId = PhoneUtils.getDefault().getDefaultSmsSubscriptionId();
@@ -246,7 +245,6 @@ public class DataModelImpl extends DataModel {
sConnectivityUtilInstanceCacheN.put( sConnectivityUtilInstanceCacheN.put(
subId, new ConnectivityUtil(mContext, subId)); subId, new ConnectivityUtil(mContext, subId));
} }
}
}); });
} }
@@ -67,12 +67,7 @@ public class DatabaseWrapper {
// track transaction on a per thread basis // track transaction on a per thread basis
private static final ThreadLocal<Stack<TransactionData>> sTransactionDepth = private static final ThreadLocal<Stack<TransactionData>> sTransactionDepth =
new ThreadLocal<Stack<TransactionData>>() { ThreadLocal.withInitial(() -> new Stack<TransactionData>());
@Override
public Stack<TransactionData> initialValue() {
return new Stack<TransactionData>();
}
};
private static final String[] sFormatStrings = new String[] { private static final String[] sFormatStrings = new String[] {
"took %d ms to %s", "took %d ms to %s",
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -25,7 +26,6 @@ import com.android.messaging.util.ContactUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
/** /**
* A cursor builder that takes the frequent contacts cursor and aggregate it with the all contacts * A cursor builder that takes the frequent contacts cursor and aggregate it with the all contacts
@@ -155,9 +155,7 @@ public class FrequentContactsCursorBuilder {
// Now we have a list of rows containing frequent contacts in alphabetical order. // Now we have a list of rows containing frequent contacts in alphabetical order.
// Therefore, sort all the rows according to their actual ranks in the frequents list. // Therefore, sort all the rows according to their actual ranks in the frequents list.
Collections.sort(rows, new Comparator<Object[]>() { Collections.sort(rows, (lhs, rhs) -> {
@Override
public int compare(final Object[] lhs, final Object[] rhs) {
final String lookupKeyLhs = (String) lhs[ContactUtil.INDEX_LOOKUP_KEY]; final String lookupKeyLhs = (String) lhs[ContactUtil.INDEX_LOOKUP_KEY];
final String lookupKeyRhs = (String) rhs[ContactUtil.INDEX_LOOKUP_KEY]; final String lookupKeyRhs = (String) rhs[ContactUtil.INDEX_LOOKUP_KEY];
Assert.isTrue(lookupKeyToRankMap.containsKey(lookupKeyLhs) && Assert.isTrue(lookupKeyToRankMap.containsKey(lookupKeyLhs) &&
@@ -187,7 +185,6 @@ public class FrequentContactsCursorBuilder {
(phoneTypeLhs == phoneTypeRhs ? 0 : 1); (phoneTypeLhs == phoneTypeRhs ? 0 : 1);
} }
} }
}
}); });
// Finally, add all the rows to this cursor. // Finally, add all the rows to this cursor.
@@ -96,20 +96,13 @@ public class ParticipantRefresh {
private static volatile boolean sObserverInitialized = false; private static volatile boolean sObserverInitialized = false;
private static final Object sLock = new Object(); private static final Object sLock = new Object();
private static final AtomicBoolean sFullRefreshScheduled = new AtomicBoolean(false); private static final AtomicBoolean sFullRefreshScheduled = new AtomicBoolean(false);
private static final Runnable sFullRefreshRunnable = new Runnable() { private static final Runnable sFullRefreshRunnable = () -> {
@Override
public void run() {
final boolean oldScheduled = sFullRefreshScheduled.getAndSet(false); final boolean oldScheduled = sFullRefreshScheduled.getAndSet(false);
Assert.isTrue(oldScheduled); Assert.isTrue(oldScheduled);
refreshParticipants(REFRESH_MODE_FULL); refreshParticipants(REFRESH_MODE_FULL);
}
}; };
private static final Runnable sSelfOnlyRefreshRunnable = new Runnable() { private static final Runnable sSelfOnlyRefreshRunnable = () ->
@Override
public void run() {
refreshParticipants(REFRESH_MODE_SELF_ONLY); refreshParticipants(REFRESH_MODE_SELF_ONLY);
}
};
/** /**
* A customized content resolver to track contact changes. * A customized content resolver to track contact changes.
@@ -303,9 +303,7 @@ public class ActionMonitor {
} }
if (completedListener != null) { if (completedListener != null) {
// Marshal to UI thread // Marshal to UI thread
mHandler.post(new Runnable() { mHandler.post(() -> {
@Override
public void run() {
ActionCompletedListener listener = null; ActionCompletedListener listener = null;
synchronized (mLock) { synchronized (mLock) {
if (mCompletedListener != null) { if (mCompletedListener != null) {
@@ -322,7 +320,6 @@ public class ActionMonitor {
action, mData, result); action, mData, result);
} }
} }
}
}); });
} }
} }
@@ -372,9 +369,7 @@ public class ActionMonitor {
} }
if (executedListener != null) { if (executedListener != null) {
// Marshal to UI thread // Marshal to UI thread
mHandler.post(new Runnable() { mHandler.post(() -> {
@Override
public void run() {
ActionExecutedListener listener = null; ActionExecutedListener listener = null;
synchronized (mLock) { synchronized (mLock) {
if (mExecutedListener != null) { if (mExecutedListener != null) {
@@ -386,7 +381,6 @@ public class ActionMonitor {
listener.onActionExecuted(ActionMonitor.this, listener.onActionExecuted(ActionMonitor.this,
action, mData, result); action, mData, result);
} }
}
}); });
} }
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -117,22 +118,13 @@ public class BugleActionToasts {
} }
private static void showToast(final int messageResId) { private static void showToast(final int messageResId) {
ThreadUtil.getMainThreadHandler().post(new Runnable() { ThreadUtil.getMainThreadHandler().post(() -> Toast.makeText(getApplicationContext(),
@Override getApplicationContext().getString(messageResId), Toast.LENGTH_LONG).show());
public void run() {
Toast.makeText(getApplicationContext(),
getApplicationContext().getString(messageResId), Toast.LENGTH_LONG).show();
}
});
} }
private static void showToast(final String message) { private static void showToast(final String message) {
ThreadUtil.getMainThreadHandler().post(new Runnable() { ThreadUtil.getMainThreadHandler().post(() ->
@Override Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show());
public void run() {
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
}
});
} }
private static Context getApplicationContext() { private static Context getApplicationContext() {
@@ -61,9 +61,7 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
private static final String KEY_SUB_ID = "sub_id"; private static final String KEY_SUB_ID = "sub_id";
public static void processFirstPendingMessage() { public static void processFirstPendingMessage() {
PhoneUtils.forEachActiveSubscription(new PhoneUtils.SubscriptionRunnable() { PhoneUtils.forEachActiveSubscription(subId -> {
@Override
public void runForSubscription(final int subId) {
// Clear any pending alarms or connectivity events // Clear any pending alarms or connectivity events
unregister(subId); unregister(subId);
// Clear retry count // Clear retry count
@@ -72,7 +70,6 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
final ProcessPendingMessagesAction action = new ProcessPendingMessagesAction(); final ProcessPendingMessagesAction action = new ProcessPendingMessagesAction();
action.actionParameters.putInt(KEY_SUB_ID, subId); action.actionParameters.putInt(KEY_SUB_ID, subId);
action.start(); action.start();
}
}); });
} }
@@ -114,9 +111,7 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
} }
if (getHavePendingMessages(subId) || scheduleAlarm) { if (getHavePendingMessages(subId) || scheduleAlarm) {
// Still have a pending message that needs to be queued for processing // Still have a pending message that needs to be queued for processing
final ConnectivityListener listener = new ConnectivityListener() { final ConnectivityListener listener = serviceState -> {
@Override
public void onPhoneStateChanged(final int serviceState) {
if (serviceState == ServiceState.STATE_IN_SERVICE) { if (serviceState == ServiceState.STATE_IN_SERVICE) {
LogUtil.i(TAG, "ProcessPendingMessagesAction: Now connected for subId " LogUtil.i(TAG, "ProcessPendingMessagesAction: Now connected for subId "
+ subId + ", starting action"); + subId + ", starting action");
@@ -131,7 +126,6 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
action.actionParameters.putInt(KEY_SUB_ID, subId); action.actionParameters.putInt(KEY_SUB_ID, subId);
action.start(); action.start();
} }
}
}; };
// Read and increment attempt number from shared prefs // Read and increment attempt number from shared prefs
final int retryAttempt = getNextRetry(subId); final int retryAttempt = getNextRetry(subId);
@@ -627,9 +627,7 @@ public class ConversationData extends BindableData {
} }
if (ContactUtil.hasReadContactsPermission()) { if (ContactUtil.hasReadContactsPermission()) {
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(() -> {
@Override
public void run() {
final DataUsageStatUpdater updater = new DataUsageStatUpdater( final DataUsageStatUpdater updater = new DataUsageStatUpdater(
Factory.get().getApplicationContext()); Factory.get().getApplicationContext());
try { try {
@@ -642,7 +640,6 @@ public class ConversationData extends BindableData {
} catch (final SQLiteFullException ex) { } catch (final SQLiteFullException ex) {
LogUtil.w(TAG, "Unable to update contact", ex); LogUtil.w(TAG, "Unable to update contact", ex);
} }
}
}); });
} }
} }
@@ -445,13 +445,9 @@ public class MessagePartData implements Parcelable {
public void destroyAsync() { public void destroyAsync() {
final Uri contentUri = shouldDestroy(); final Uri contentUri = shouldDestroy();
if (contentUri != null) { if (contentUri != null) {
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(() ->
@Override
public void run() {
Factory.get().getApplicationContext().getContentResolver().delete( Factory.get().getApplicationContext().getContentResolver().delete(
contentUri, null, null); contentUri, null, null));
}
});
} }
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,7 +21,6 @@ import android.database.Cursor;
import androidx.collection.ArrayMap; import androidx.collection.ArrayMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@@ -61,14 +61,10 @@ public class SelfParticipantsData {
list.add(self); list.add(self);
} }
} }
Collections.sort( list.sort((Comparator) (o1, o2) -> {
list,
new Comparator() {
public int compare(Object o1, Object o2) {
int slotId1 = ((ParticipantData) o1).getSlotId(); int slotId1 = ((ParticipantData) o1).getSlotId();
int slotId2 = ((ParticipantData) o2).getSlotId(); int slotId2 = ((ParticipantData) o2).getSlotId();
return slotId1 > slotId2 ? 1 : -1; return slotId1 > slotId2 ? 1 : -1;
}
}); });
return list; return list;
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -27,7 +28,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
/** /**
* <p>Loads and maintains a set of in-memory LRU caches for different types of media resources. * <p>Loads and maintains a set of in-memory LRU caches for different types of media resources.
@@ -104,13 +104,10 @@ public class MediaResourceManager {
// These tasks are run on a single worker thread with low priority so as not to contend with the // These tasks are run on a single worker thread with low priority so as not to contend with the
// media loading tasks. // media loading tasks.
private static final Executor MEDIA_BACKGROUND_EXECUTOR = Executors.newSingleThreadExecutor( private static final Executor MEDIA_BACKGROUND_EXECUTOR = Executors.newSingleThreadExecutor(
new ThreadFactory() { runnable -> {
@Override
public Thread newThread(final Runnable runnable) {
final Thread encodingThread = new Thread(runnable); final Thread encodingThread = new Thread(runnable);
encodingThread.setPriority(Thread.MIN_PRIORITY); encodingThread.setPriority(Thread.MIN_PRIORITY);
return encodingThread; return encodingThread;
}
}); });
/** /**
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -71,13 +72,9 @@ public class VCardResourceEntry {
void close() { void close() {
// If the avatar image was temporarily saved in the scratch folder, remove that. // If the avatar image was temporarily saved in the scratch folder, remove that.
if (MediaScratchFileProvider.isMediaScratchSpaceUri(mAvatarUri)) { if (MediaScratchFileProvider.isMediaScratchSpaceUri(mAvatarUri)) {
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(() ->
@Override
public void run() {
Factory.get().getApplicationContext().getContentResolver().delete( Factory.get().getApplicationContext().getContentResolver().delete(
mAvatarUri, null, null); mAvatarUri, null, null));
}
});
} }
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -336,12 +337,8 @@ public class ApnDatabase extends SQLiteOpenHelper {
final Resources r = sContext.getResources(); final Resources r = sContext.getResources();
final XmlResourceParser parser = r.getXml(R.xml.apns); final XmlResourceParser parser = r.getXml(R.xml.apns);
final ApnsXmlProcessor processor = ApnsXmlProcessor.get(parser); final ApnsXmlProcessor processor = ApnsXmlProcessor.get(parser);
processor.setApnHandler(new ApnsXmlProcessor.ApnHandler() { processor.setApnHandler(apnValues -> db.insert(APN_TABLE, null/*nullColumnHack*/,
@Override apnValues));
public void process(final ContentValues apnValues) {
db.insert(APN_TABLE, null/*nullColumnHack*/, apnValues);
}
});
try { try {
processor.process(); processor.process();
} catch (final Exception e) { } catch (final Exception e) {
@@ -129,13 +129,8 @@ public class BugleCarrierConfigValuesLoader implements CarrierConfigValuesLoader
try { try {
parser = subContext.getResources().getXml(R.xml.mms_config); parser = subContext.getResources().getXml(R.xml.mms_config);
final ApnsXmlProcessor processor = ApnsXmlProcessor.get(parser); final ApnsXmlProcessor processor = ApnsXmlProcessor.get(parser);
processor.setMmsConfigHandler(new ApnsXmlProcessor.MmsConfigHandler() { processor.setMmsConfigHandler((mccMnc, key, value, type) ->
@Override update(values, type, key, value));
public void process(final String mccMnc, final String key, final String value,
final String type) {
update(values, type, key, value);
}
});
processor.process(); processor.process();
} catch (final Resources.NotFoundException e) { } catch (final Resources.NotFoundException e) {
LogUtil.w(LogUtil.BUGLE_TAG, "Can not find mms_config.xml"); LogUtil.w(LogUtil.BUGLE_TAG, "Can not find mms_config.xml");
+1 -6
View File
@@ -134,12 +134,7 @@ public class MmsConfig {
* Same as load() but doing it using an async thread from SafeAsyncTask thread pool. * Same as load() but doing it using an async thread from SafeAsyncTask thread pool.
*/ */
public static void loadAsync() { public static void loadAsync() {
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(MmsConfig::load);
@Override
public void run() {
load();
}
});
} }
/** /**
@@ -85,7 +85,7 @@ public class AsyncImageView extends ImageView implements MediaResourceLoadListen
// setting is null (no placeholder). // setting is null (no placeholder).
private final Drawable mPlaceholderDrawable; private final Drawable mPlaceholderDrawable;
protected ImageResource mImageResource; protected ImageResource mImageResource;
private final Runnable mDisposeRunnable = new Runnable() { private final Runnable mDisposeRunnable = () -> new Runnable() {
@Override @Override
public void run() { public void run() {
if (mImageRequestBinding.isBound()) { if (mImageRequestBinding.isBound()) {
@@ -71,35 +71,22 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
mCloseButton = (ImageButton) findViewById(R.id.close_button); mCloseButton = (ImageButton) findViewById(R.id.close_button);
mCloseButton.setOnClickListener(new OnClickListener() { mCloseButton.setOnClickListener(view -> mComposeMessageView.clearAttachments());
@Override
public void onClick(final View view) {
mComposeMessageView.clearAttachments();
}
});
mAttachmentView = (FrameLayout) findViewById(R.id.attachment_view); mAttachmentView = (FrameLayout) findViewById(R.id.attachment_view);
// The attachment preview is a scroll view so that it can show the bottom portion of the // 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 // attachment whenever the space is tight (e.g. when in landscape mode). Per design
// request we'd like to make the attachment view always scrolled to the bottom. // request we'd like to make the attachment view always scrolled to the bottom.
addOnLayoutChangeListener(new OnLayoutChangeListener() { addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight,
@Override oldBottom) -> post(() ->
public void onLayoutChange(final View v, final int left, final int top, final int right, {
final int bottom, final int oldLeft, final int oldTop, final int oldRight,
final int oldBottom) {
post(new Runnable() {
@Override
public void run() {
final int childCount = getChildCount(); final int childCount = getChildCount();
if (childCount > 0) { if (childCount > 0) {
final View lastChild = getChildAt(childCount - 1); final View lastChild = getChildAt(childCount - 1);
scrollTo(getScrollX(), lastChild.getBottom() - getHeight()); scrollTo(getScrollX(), lastChild.getBottom() - getHeight());
} }
} }));
});
}
});
mPendingFirstUpdate = true; mPendingFirstUpdate = true;
} }
@@ -129,17 +116,13 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
mPendingHideCanceled = false; mPendingHideCanceled = false;
final View viewToHide = mAttachmentView.getChildCount() > 1 ? final View viewToHide = mAttachmentView.getChildCount() > 1 ?
mAttachmentView : mAttachmentView.getChildAt(0); mAttachmentView : mAttachmentView.getChildAt(0);
UiUtils.revealOrHideViewWithAnimation(viewToHide, INVISIBLE, UiUtils.revealOrHideViewWithAnimation(viewToHide, INVISIBLE, () -> {
new Runnable() {
@Override
public void run() {
// Only hide if we are didn't get overruled by showing // Only hide if we are didn't get overruled by showing
if (!mPendingHideCanceled) { if (!mPendingHideCanceled) {
stopPopupAnimation(); stopPopupAnimation();
mAttachmentView.removeAllViews(); mAttachmentView.removeAllViews();
setVisibility(GONE); setVisibility(GONE);
} }
}
}); });
} else { } else {
mAttachmentView.removeAllViews(); mAttachmentView.removeAllViews();
@@ -164,15 +147,12 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
.getQuantityString(R.plurals.attachment_preview_close_content_description, .getQuantityString(R.plurals.attachment_preview_close_content_description,
combinedAttachmentCount)); combinedAttachmentCount));
if (combinedAttachmentCount == 0) { if (combinedAttachmentCount == 0) {
mHideRunnable = new Runnable() { mHideRunnable = () -> {
@Override
public void run() {
mHideRunnable = null; mHideRunnable = null;
// Only start the hiding if there are still no attachments // Only start the hiding if there are still no attachments
if (attachments.size() + pendingAttachments.size() == 0) { if (attachments.size() + pendingAttachments.size() == 0) {
hideAttachmentPreview(); hideAttachmentPreview();
} }
}
}; };
if (draftMessageData.isSending()) { if (draftMessageData.isSending()) {
// Wait to hide until the message is ready to start animating // Wait to hide until the message is ready to start animating
@@ -196,13 +176,11 @@ public class AttachmentPreview extends ScrollView implements OnAttachmentClickLi
if (!isFirstUpdate) { if (!isFirstUpdate) {
// Reveal the close button after the view animates in. // Reveal the close button after the view animates in.
mCloseButton.setVisibility(INVISIBLE); mCloseButton.setVisibility(INVISIBLE);
ThreadUtil.getMainThreadHandler().postDelayed(new Runnable() { ThreadUtil.getMainThreadHandler().postDelayed(() ->
@Override
public void run() {
UiUtils.revealOrHideViewWithAnimation(mCloseButton, VISIBLE, UiUtils.revealOrHideViewWithAnimation(mCloseButton, VISIBLE,
null /* onFinishRunnable */); null /* onFinishRunnable */),
} UiUtils.MEDIAPICKER_TRANSITION_DURATION +
}, UiUtils.MEDIAPICKER_TRANSITION_DURATION + CLOSE_BUTTON_REVEAL_STAGGER_MILLIS); CLOSE_BUTTON_REVEAL_STAGGER_MILLIS);
} }
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -23,8 +24,6 @@ import androidx.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout.LayoutParams; import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView; import android.widget.ImageView;
@@ -93,21 +92,15 @@ public class AttachmentPreviewFactory {
} }
if (attachmentView != null && clickListener != null) { if (attachmentView != null && clickListener != null) {
attachmentView.setOnClickListener(new OnClickListener() { attachmentView.setOnClickListener(view -> {
@Override
public void onClick(final View view) {
final Rect bounds = UiUtils.getMeasuredBoundsOnScreen(view); final Rect bounds = UiUtils.getMeasuredBoundsOnScreen(view);
clickListener.onAttachmentClick(attachmentData, bounds, clickListener.onAttachmentClick(attachmentData, bounds,
false /* longPress */); false /* longPress */);
}
}); });
attachmentView.setOnLongClickListener(new OnLongClickListener() { attachmentView.setOnLongClickListener(view -> {
@Override
public boolean onLongClick(final View view) {
final Rect bounds = UiUtils.getMeasuredBoundsOnScreen(view); final Rect bounds = UiUtils.getMeasuredBoundsOnScreen(view);
return clickListener.onAttachmentClick(attachmentData, bounds, return clickListener.onAttachmentClick(attachmentData, bounds,
true /* longPress */); true /* longPress */);
}
}); });
} }
return attachmentView; return attachmentView;
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,9 +23,6 @@ import android.graphics.Path;
import android.graphics.RectF; import android.graphics.RectF;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri; import android.net.Uri;
import android.os.SystemClock; import android.os.SystemClock;
import android.text.TextUtils; import android.text.TextUtils;
@@ -106,9 +104,7 @@ public class AudioAttachmentView extends LinearLayout {
mPlayPauseButton = (AudioAttachmentPlayPauseButton) findViewById(R.id.play_pause_button); mPlayPauseButton = (AudioAttachmentPlayPauseButton) findViewById(R.id.play_pause_button);
mChronometer = (PausableChronometer) findViewById(R.id.timer); mChronometer = (PausableChronometer) findViewById(R.id.timer);
mProgressBar = (AudioPlaybackProgressBar) findViewById(R.id.progress); mProgressBar = (AudioPlaybackProgressBar) findViewById(R.id.progress);
mPlayPauseButton.setOnClickListener(new OnClickListener() { mPlayPauseButton.setOnClickListener(v -> {
@Override
public void onClick(final View v) {
// Has the MediaPlayer already been prepared? // Has the MediaPlayer already been prepared?
if (mMediaPlayer != null && mPrepared) { if (mMediaPlayer != null && mPrepared) {
if (mMediaPlayer.isPlaying()) { if (mMediaPlayer.isPlaying()) {
@@ -131,7 +127,6 @@ public class AudioAttachmentView extends LinearLayout {
} }
} }
updatePlayPauseButtonState(); updatePlayPauseButtonState();
}
}); });
updatePlayPauseButtonState(); updatePlayPauseButtonState();
initializeViewsForMode(); initializeViewsForMode();
@@ -217,9 +212,7 @@ public class AudioAttachmentView extends LinearLayout {
try { try {
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setDataSource(Factory.get().getApplicationContext(), mDataSourceUri); mMediaPlayer.setDataSource(Factory.get().getApplicationContext(), mDataSourceUri);
mMediaPlayer.setOnCompletionListener(new OnCompletionListener() { mMediaPlayer.setOnCompletionListener(mp -> {
@Override
public void onCompletion(final MediaPlayer mp) {
updatePlayPauseButtonState(); updatePlayPauseButtonState();
mChronometer.reset(); mChronometer.reset();
mChronometer.setBase(SystemClock.elapsedRealtime() - mChronometer.setBase(SystemClock.elapsedRealtime() -
@@ -228,12 +221,9 @@ public class AudioAttachmentView extends LinearLayout {
mProgressBar.reset(); mProgressBar.reset();
mPlaybackFinished = true; mPlaybackFinished = true;
}
}); });
mMediaPlayer.setOnPreparedListener(new OnPreparedListener() { mMediaPlayer.setOnPreparedListener(mp -> {
@Override
public void onPrepared(final MediaPlayer mp) {
// Set base on the chronometer so we can show the full length of the audio. // Set base on the chronometer so we can show the full length of the audio.
mChronometer.setBase(SystemClock.elapsedRealtime() - mChronometer.setBase(SystemClock.elapsedRealtime() -
mMediaPlayer.getDuration()); mMediaPlayer.getDuration());
@@ -246,16 +236,12 @@ public class AudioAttachmentView extends LinearLayout {
playAudio(); playAudio();
updatePlayPauseButtonState(); updatePlayPauseButtonState();
} }
}
}); });
mMediaPlayer.setOnErrorListener(new OnErrorListener() { mMediaPlayer.setOnErrorListener((mp, what, extra) -> {
@Override
public boolean onError(final MediaPlayer mp, final int what, final int extra) {
mStartPlayAfterPrepare = false; mStartPlayAfterPrepare = false;
onAudioReplayError(what, extra, null); onAudioReplayError(what, extra, null);
return true; return true;
}
}); });
mMediaPlayer.prepareAsync(); mMediaPlayer.prepareAsync();
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -17,7 +18,6 @@ package com.android.messaging.ui;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.TimeAnimator; import android.animation.TimeAnimator;
import android.animation.TimeAnimator.TimeListener;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.ClipDrawable; import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@@ -41,10 +41,7 @@ public class AudioPlaybackProgressBar extends ProgressBar implements PlaybackSta
mUpdateAnimator = new TimeAnimator(); mUpdateAnimator = new TimeAnimator();
mUpdateAnimator.setRepeatCount(ObjectAnimator.INFINITE); mUpdateAnimator.setRepeatCount(ObjectAnimator.INFINITE);
mUpdateAnimator.setTimeListener(new TimeListener() { mUpdateAnimator.setTimeListener((animation, totalTime, deltaTime) -> {
@Override
public void onTimeUpdate(final TimeAnimator animation, final long totalTime,
final long deltaTime) {
int progress = 0; int progress = 0;
if (mDurationInMillis > 0) { if (mDurationInMillis > 0) {
progress = (int) (((mCumulativeTime + SystemClock.elapsedRealtime() - progress = (int) (((mCumulativeTime + SystemClock.elapsedRealtime() -
@@ -52,7 +49,6 @@ public class AudioPlaybackProgressBar extends ProgressBar implements PlaybackSta
progress = Math.max(Math.min(progress, 100), 0); progress = Math.max(Math.min(progress, 100), 0);
} }
setProgress(progress); setProgress(progress);
}
}); });
updateAppearance(); updateAppearance();
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -19,7 +20,6 @@ import android.content.Context;
import androidx.core.text.BidiFormatter; import androidx.core.text.BidiFormatter;
import androidx.core.text.TextDirectionHeuristicsCompat; import androidx.core.text.TextDirectionHeuristicsCompat;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@@ -44,12 +44,7 @@ public class BlockedParticipantListItemView extends LinearLayout {
protected void onFinishInflate() { protected void onFinishInflate() {
mNameTextView = (TextView) findViewById(R.id.name); mNameTextView = (TextView) findViewById(R.id.name);
mContactIconView = (ContactIconView) findViewById(R.id.contact_icon); mContactIconView = (ContactIconView) findViewById(R.id.contact_icon);
setOnClickListener(new OnClickListener() { setOnClickListener(v -> mData.unblock(getContext()));
@Override
public void onClick(final View v) {
mData.unblock(getContext());
}
});
} }
public void bind(final ParticipantListItemData data) { public void bind(final ParticipantListItemData data) {
@@ -20,7 +20,6 @@ package com.android.messaging.ui;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@@ -188,21 +187,15 @@ public class ClassZeroActivity extends Activity {
} }
} }
private final OnClickListener mCancelListener = new OnClickListener() { private final OnClickListener mCancelListener = (dialog, whichButton) -> {
@Override
public void onClick(final DialogInterface dialog, final int whichButton) {
dialog.dismiss(); dialog.dismiss();
processNextMessage(); processNextMessage();
}
}; };
private final OnClickListener mSaveListener = new OnClickListener() { private final OnClickListener mSaveListener = (dialog, whichButton) -> {
@Override
public void onClick(final DialogInterface dialog, final int whichButton) {
mRead = true; mRead = true;
saveMessage(); saveMessage();
dialog.dismiss(); dialog.dismiss();
processNextMessage(); processNextMessage();
}
}; };
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,7 +23,6 @@ import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.datamodel.data.ParticipantData; import com.android.messaging.datamodel.data.ParticipantData;
@@ -134,13 +134,8 @@ public class ContactIconView extends AsyncImageView {
&& !TextUtils.isEmpty(mContactLookupKey)) || && !TextUtils.isEmpty(mContactLookupKey)) ||
!TextUtils.isEmpty(mNormalizedDestination)) { !TextUtils.isEmpty(mNormalizedDestination)) {
if (!mDisableClickHandler) { if (!mDisableClickHandler) {
setOnClickListener(new View.OnClickListener() { setOnClickListener(view -> ContactUtil.showOrAddContact(view, mContactId,
@Override mContactLookupKey, mAvatarUri, mNormalizedDestination));
public void onClick(final View view) {
ContactUtil.showOrAddContact(view, mContactId, mContactLookupKey,
mAvatarUri, mNormalizedDestination);
}
});
} }
} else { } else {
// This should happen when the phone number is not in the user's contacts or it is a // This should happen when the phone number is not in the user's contacts or it is a
@@ -24,7 +24,6 @@ import android.os.Bundle;
import android.os.SystemClock; import android.os.SystemClock;
import android.provider.Settings; import android.provider.Settings;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@@ -57,29 +56,16 @@ public class PermissionCheckActivity extends Activity {
setContentView(R.layout.permission_check_activity); setContentView(R.layout.permission_check_activity);
UiUtils.setStatusBarColor(this, getColor(R.color.permission_check_activity_background)); UiUtils.setStatusBarColor(this, getColor(R.color.permission_check_activity_background));
findViewById(R.id.exit).setOnClickListener(new OnClickListener() { findViewById(R.id.exit).setOnClickListener(view -> finish());
@Override
public void onClick(final View view) {
finish();
}
});
mNextView = (TextView) findViewById(R.id.next); mNextView = (TextView) findViewById(R.id.next);
mNextView.setOnClickListener(new OnClickListener() { mNextView.setOnClickListener(view -> tryRequestPermission());
@Override
public void onClick(final View view) {
tryRequestPermission();
}
});
mSettingsView = (TextView) findViewById(R.id.settings); mSettingsView = (TextView) findViewById(R.id.settings);
mSettingsView.setOnClickListener(new OnClickListener() { mSettingsView.setOnClickListener(view -> {
@Override
public void onClick(final View view) {
final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.parse(PACKAGE_URI_PREFIX + getPackageName())); Uri.parse(PACKAGE_URI_PREFIX + getPackageName()));
startActivity(intent); startActivity(intent);
}
}); });
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -168,22 +169,16 @@ public class PersonItemView extends LinearLayout implements PersonItemDataListen
if (mListener == null) { if (mListener == null) {
return; return;
} }
setOnClickListener(new OnClickListener() { setOnClickListener(v -> {
@Override
public void onClick(final View v) {
if (mListener != null && mBinding.isBound()) { if (mListener != null && mBinding.isBound()) {
mListener.onPersonClicked(mBinding.getData()); mListener.onPersonClicked(mBinding.getData());
} }
}
}); });
final OnLongClickListener onLongClickListener = new OnLongClickListener() { final OnLongClickListener onLongClickListener = v -> {
@Override
public boolean onLongClick(View v) {
if (mListener != null && mBinding.isBound()) { if (mListener != null && mBinding.isBound()) {
return mListener.onPersonLongClicked(mBinding.getData()); return mListener.onPersonLongClicked(mBinding.getData());
} }
return false; return false;
}
}; };
setOnLongClickListener(onLongClickListener); setOnLongClickListener(onLongClickListener);
mContactIconView.setOnLongClickListener(onLongClickListener); mContactIconView.setOnLongClickListener(onLongClickListener);
@@ -28,7 +28,6 @@ import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
@@ -108,12 +107,7 @@ public class SmsStorageLowWarningFragment extends Fragment {
builder.setTitle(R.string.sms_storage_low_title) builder.setTitle(R.string.sms_storage_low_title)
.setView(dialogLayout) .setView(dialogLayout)
.setNegativeButton(R.string.ignore, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.ignore, (dialog, id) -> dialog.cancel());
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
final Dialog dialog = builder.create(); final Dialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false); dialog.setCanceledOnTouchOutside(false);
@@ -145,12 +139,9 @@ public class SmsStorageLowWarningFragment extends Fragment {
final String action = getItem(position); final String action = getItem(position);
actionItemView.setText(action); actionItemView.setText(action);
actionItemView.setOnClickListener(new OnClickListener() { actionItemView.setOnClickListener(view1 -> {
@Override
public void onClick(final View view) {
dismiss(); dismiss();
((SmsStorageLowWarningFragment) getTargetFragment()).confirm(position); ((SmsStorageLowWarningFragment) getTargetFragment()).confirm(position);
}
}); });
return actionItemView; return actionItemView;
} }
@@ -191,25 +182,15 @@ public class SmsStorageLowWarningFragment extends Fragment {
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.sms_storage_low_title) builder.setTitle(R.string.sms_storage_low_title)
.setMessage(getConfirmDialogMessage(actionIndex)) .setMessage(getConfirmDialogMessage(actionIndex))
.setNegativeButton(android.R.string.cancel, .setNegativeButton(android.R.string.cancel, (dialog, button) -> {
new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog,
final int button) {
dismiss(); dismiss();
((SmsStorageLowWarningFragment) getTargetFragment()).cancel(); ((SmsStorageLowWarningFragment) getTargetFragment()).cancel();
}
}) })
.setPositiveButton(android.R.string.ok, .setPositiveButton(android.R.string.ok, (dialog, button) -> {
new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog,
final int button) {
dismiss(); dismiss();
handleAction(actionIndex); handleAction(actionIndex);
getActivity().finish(); getActivity().finish();
SmsStorageStatusManager.cancelStorageLowNotification(); SmsStorageStatusManager.cancelStorageLowNotification();
}
}); });
return builder.create(); return builder.create();
} }
+1 -5
View File
@@ -22,7 +22,6 @@ import androidx.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.MarginLayoutParams; import android.view.ViewGroup.MarginLayoutParams;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
@@ -292,14 +291,11 @@ public class SnackBar {
} else { } else {
mActionTextView.setVisibility(View.VISIBLE); mActionTextView.setVisibility(View.VISIBLE);
mActionTextView.setText(mAction.getActionLabel()); mActionTextView.setText(mAction.getActionLabel());
mActionTextView.setOnClickListener(new OnClickListener() { mActionTextView.setOnClickListener(v -> {
@Override
public void onClick(final View v) {
mAction.getActionRunnable().run(); mAction.getActionRunnable().run();
if (mListener != null) { if (mListener != null) {
mListener.onActionClick(); mListener.onActionClick();
} }
}
}); });
} }
} }
@@ -23,7 +23,6 @@ import android.os.Handler;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.Gravity; import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.MeasureSpec; import android.view.View.MeasureSpec;
import android.view.View.OnAttachStateChangeListener; import android.view.View.OnAttachStateChangeListener;
@@ -34,7 +33,6 @@ import android.view.ViewPropertyAnimator;
import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@@ -66,28 +64,15 @@ public class SnackBarManager {
return sInstance; return sInstance;
} }
private final Runnable mDismissRunnable = new Runnable() { private final Runnable mDismissRunnable = this::dismiss;
@Override
public void run() {
dismiss();
}
};
private final OnTouchListener mDismissOnTouchListener = new OnTouchListener() { private final OnTouchListener mDismissOnTouchListener = (view, event) -> {
@Override
public boolean onTouch(final View view, final MotionEvent event) {
// Dismiss the {@link SnackBar} but don't consume the event. // Dismiss the {@link SnackBar} but don't consume the event.
dismiss(); dismiss();
return false; return false;
}
}; };
private final SnackBarListener mDismissOnUserTapListener = new SnackBarListener() { private final SnackBarListener mDismissOnUserTapListener = this::dismiss;
@Override
public void onActionClick() {
dismiss();
}
};
private final OnAttachStateChangeListener mAttachStateChangeListener = private final OnAttachStateChangeListener mAttachStateChangeListener =
new OnAttachStateChangeListener() { new OnAttachStateChangeListener() {
@@ -184,20 +169,12 @@ public class SnackBarManager {
// You'd expect PopupWindow.showAsDropDown to ensure the popup moves with the anchor // You'd expect PopupWindow.showAsDropDown to ensure the popup moves with the anchor
// view, which it does for scrolling, but not layout changes, so we have to manually // view, which it does for scrolling, but not layout changes, so we have to manually
// update while the snackbar is showing // update while the snackbar is showing
final OnGlobalLayoutListener listener = new OnGlobalLayoutListener() { final OnGlobalLayoutListener listener = () ->
@Override
public void onGlobalLayout() {
mPopupWindow.update(anchorView, 0, getRelativeOffset(snackBar), mPopupWindow.update(anchorView, 0, getRelativeOffset(snackBar),
anchorView.getWidth(), LayoutParams.WRAP_CONTENT); anchorView.getWidth(), LayoutParams.WRAP_CONTENT);
}
};
anchorView.getViewTreeObserver().addOnGlobalLayoutListener(listener); anchorView.getViewTreeObserver().addOnGlobalLayoutListener(listener);
mPopupWindow.setOnDismissListener(new OnDismissListener() { mPopupWindow.setOnDismissListener(() ->
@Override anchorView.getViewTreeObserver().removeOnGlobalLayoutListener(listener));
public void onDismiss() {
anchorView.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
}
});
mPopupWindow.showAsDropDown(anchorView, 0, getRelativeOffset(snackBar)); mPopupWindow.showAsDropDown(anchorView, 0, getRelativeOffset(snackBar));
} }
@@ -205,9 +182,7 @@ public class SnackBarManager {
// Animate the toast bar into view. // Animate the toast bar into view.
placeSnackBarOffScreen(snackBar); placeSnackBarOffScreen(snackBar);
animateSnackBarOnScreen(snackBar).withEndAction(new Runnable() { animateSnackBarOnScreen(snackBar).withEndAction(() -> {
@Override
public void run() {
mCurrentSnackBar.setEnabled(true); mCurrentSnackBar.setEnabled(true);
makeCurrentSnackBarDismissibleOnTouch(); makeCurrentSnackBarDismissibleOnTouch();
// Fire an accessibility event as needed // Fire an accessibility event as needed
@@ -222,7 +197,6 @@ public class SnackBarManager {
AccessibilityUtil.announceForAccessibilityCompat(snackBar.getSnackBarView(), AccessibilityUtil.announceForAccessibilityCompat(snackBar.getSnackBarView(),
null /*accessibilityManager*/, snackBarText); null /*accessibilityManager*/, snackBarText);
} }
}
}); });
// Animate any interaction views out of the way. // Animate any interaction views out of the way.
@@ -249,9 +223,7 @@ public class SnackBarManager {
// Animate the toast bar down. // Animate the toast bar down.
final View rootView = snackBar.getRootView(); final View rootView = snackBar.getRootView();
animateSnackBarOffScreen(snackBar).withEndAction(new Runnable() { animateSnackBarOffScreen(snackBar).withEndAction(() -> {
@Override
public void run() {
rootView.setVisibility(View.GONE); rootView.setVisibility(View.GONE);
try { try {
mPopupWindow.dismiss(); mPopupWindow.dismiss();
@@ -271,7 +243,6 @@ public class SnackBarManager {
mNextSnackBar = null; mNextSnackBar = null;
show(localNextSnackBar); show(localNextSnackBar);
} }
}
}); });
// Animate any interaction views back. // Animate any interaction views back.
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -25,11 +26,9 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ExpandableListAdapter; import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.datamodel.DataModel; import com.android.messaging.datamodel.DataModel;
@@ -73,20 +72,14 @@ public class VCardDetailFragment extends Fragment implements PersonItemDataListe
Assert.notNull(mVCardUri); Assert.notNull(mVCardUri);
final View view = inflater.inflate(R.layout.vcard_detail_fragment, container, false); final View view = inflater.inflate(R.layout.vcard_detail_fragment, container, false);
mListView = (ExpandableListView) view.findViewById(R.id.list); mListView = (ExpandableListView) view.findViewById(R.id.list);
mListView.addOnLayoutChangeListener(new OnLayoutChangeListener() { mListView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight,
@Override oldBottom) -> {
public void onLayoutChange(final View v, final int left, final int top, final int right, mListView.setIndicatorBounds(mListView.getWidth() - getResources().
final int bottom, final int oldLeft, final int oldTop, final int oldRight, getDimensionPixelSize(R.dimen.vcard_detail_group_indicator_width),
final int oldBottom) {
mListView.setIndicatorBounds(mListView.getWidth() - getResources()
.getDimensionPixelSize(R.dimen.vcard_detail_group_indicator_width),
mListView.getWidth()); mListView.getWidth());
}
}); });
mListView.setOnChildClickListener(new OnChildClickListener() { mListView.setOnChildClickListener((expandableListView, clickedView, groupPosition,
@Override childPosition, childId) -> {
public boolean onChildClick(ExpandableListView expandableListView, View clickedView,
int groupPosition, int childPosition, long childId) {
if (!(clickedView instanceof PersonItemView)) { if (!(clickedView instanceof PersonItemView)) {
return false; return false;
} }
@@ -100,7 +93,6 @@ public class VCardDetailFragment extends Fragment implements PersonItemDataListe
return true; return true;
} }
return false; return false;
}
}); });
mBinding.bind(DataModel.get().createVCardContactItemData(getActivity(), mVCardUri)); mBinding.bind(DataModel.get().createVCardContactItemData(getActivity(), mVCardUri));
mBinding.getData().setListener(this); mBinding.getData().setListener(this);
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -95,15 +96,12 @@ public class VideoThumbnailView extends FrameLayout {
mVideoView.clearFocus(); mVideoView.clearFocus();
addView(mVideoView, 0, new ViewGroup.LayoutParams( addView(mVideoView, 0, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { mVideoView.setOnPreparedListener(mediaPlayer -> {
@Override
public void onPrepared(final MediaPlayer mediaPlayer) {
mVideoLoaded = true; mVideoLoaded = true;
mVideoWidth = mediaPlayer.getVideoWidth(); mVideoWidth = mediaPlayer.getVideoWidth();
mVideoHeight = mediaPlayer.getVideoHeight(); mVideoHeight = mediaPlayer.getVideoHeight();
mediaPlayer.setLooping(loop); mediaPlayer.setLooping(loop);
trySwitchToVideo(); trySwitchToVideo();
}
}); });
mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override @Override
@@ -111,12 +109,7 @@ public class VideoThumbnailView extends FrameLayout {
mPlayButton.setVisibility(View.VISIBLE); mPlayButton.setVisibility(View.VISIBLE);
} }
}); });
mVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { mVideoView.setOnErrorListener((mediaPlayer, i, i2) -> true);
@Override
public boolean onError(final MediaPlayer mediaPlayer, final int i, final int i2) {
return true;
}
});
} else { } else {
mVideoView = null; mVideoView = null;
} }
@@ -125,9 +118,7 @@ public class VideoThumbnailView extends FrameLayout {
if (loop) { if (loop) {
mPlayButton.setVisibility(View.GONE); mPlayButton.setVisibility(View.GONE);
} else { } else {
mPlayButton.setOnClickListener(new OnClickListener() { mPlayButton.setOnClickListener(view -> {
@Override
public void onClick(final View view) {
if (mVideoSource == null) { if (mVideoSource == null) {
return; return;
} }
@@ -138,15 +129,11 @@ public class VideoThumbnailView extends FrameLayout {
} else { } else {
UIIntents.get().launchFullScreenVideoViewer(getContext(), mVideoSource); UIIntents.get().launchFullScreenVideoViewer(getContext(), mVideoSource);
} }
}
}); });
mPlayButton.setOnLongClickListener(new OnLongClickListener() { mPlayButton.setOnLongClickListener(view -> {
@Override
public boolean onLongClick(final View view) {
// Button prevents long click from propagating up, do it manually // Button prevents long click from propagating up, do it manually
VideoThumbnailView.this.performLongClick(); VideoThumbnailView.this.performLongClick();
return true; return true;
}
}); });
} }
@@ -157,12 +157,7 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP
textView.setText(tabTitle); textView.setText(tabTitle);
textView.setBackgroundResource(R.drawable.contact_picker_tab_background_selector); textView.setBackgroundResource(R.drawable.contact_picker_tab_background_selector);
textView.setGravity(Gravity.CENTER); textView.setGravity(Gravity.CENTER);
textView.setOnClickListener(new OnClickListener() { textView.setOnClickListener(v -> mPager.setCurrentItem(getRtlPosition(position)));
@Override
public void onClick(View v) {
mPager.setCurrentItem(getRtlPosition(position));
}
});
// Assign various text appearance related attributes to child views. // Assign various text appearance related attributes to child views.
if (mTextStyle > 0) { if (mTextStyle > 0) {
@@ -112,12 +112,8 @@ public class PopupTransitionAnimation extends Animation {
} }
private final StringBuilder mEvents = new StringBuilder(); private final StringBuilder mEvents = new StringBuilder();
private final Runnable mCleanupRunnable = new Runnable() { private final Runnable mCleanupRunnable = () ->
@Override
public void run() {
LogUtil.w(LogUtil.BUGLE_TAG, "PopupTransitionAnimation: " + mEvents); LogUtil.w(LogUtil.BUGLE_TAG, "PopupTransitionAnimation: " + mEvents);
}
};
/** /**
* Ensures the animation is ready before starting the animation. * Ensures the animation is ready before starting the animation.
@@ -210,9 +206,7 @@ public class PopupTransitionAnimation extends Animation {
mViewToAnimate.setVisibility(View.VISIBLE); mViewToAnimate.setVisibility(View.VISIBLE);
// Delay dismissing the popup window to let mViewToAnimate draw under it and reduce the // Delay dismissing the popup window to let mViewToAnimate draw under it and reduce the
// flash // flash
ThreadUtil.getMainThreadHandler().post(new Runnable() { ThreadUtil.getMainThreadHandler().post(() -> {
@Override
public void run() {
try { try {
mPopupWindow.dismiss(); mPopupWindow.dismiss();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@@ -220,7 +214,6 @@ public class PopupTransitionAnimation extends Animation {
// has already ended while we were animating // has already ended while we were animating
} }
ThreadUtil.getMainThreadHandler().removeCallbacks(mCleanupRunnable); ThreadUtil.getMainThreadHandler().removeCallbacks(mCleanupRunnable);
}
}); });
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -168,16 +169,13 @@ public class ViewGroupItemVerticalExplodeAnimation {
expandLayer.animate().scaleY(scale) expandLayer.animate().scaleY(scale)
.setDuration(mDuration) .setDuration(mDuration)
.setInterpolator(UiUtils.EASE_IN_INTERPOLATOR) .setInterpolator(UiUtils.EASE_IN_INTERPOLATOR)
.withEndAction(new Runnable() { .withEndAction(() -> {
@Override
public void run() {
// Clean up the views added to overlay on animation finish. // Clean up the views added to overlay on animation finish.
overlay.remove(shadowContainerLayer); overlay.remove(shadowContainerLayer);
mViewToAnimate.setBackground(oldBackground); mViewToAnimate.setBackground(oldBackground);
if (mViewBitmap != null) { if (mViewBitmap != null) {
mViewBitmap.recycle(); mViewBitmap.recycle();
} }
}
}); });
} }
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -19,7 +20,6 @@ import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RadioButton; import android.widget.RadioButton;
import com.android.messaging.R; import com.android.messaging.R;
@@ -70,18 +70,8 @@ public class GroupMmsSettingDialog {
rootView.findViewById(R.id.disable_group_mms_button); rootView.findViewById(R.id.disable_group_mms_button);
final RadioButton enableButton = (RadioButton) final RadioButton enableButton = (RadioButton)
rootView.findViewById(R.id.enable_group_mms_button); rootView.findViewById(R.id.enable_group_mms_button);
disableButton.setOnClickListener(new OnClickListener() { disableButton.setOnClickListener(view -> changeGroupMmsSettings(false));
@Override enableButton.setOnClickListener(view -> changeGroupMmsSettings(true));
public void onClick(View view) {
changeGroupMmsSettings(false);
}
});
enableButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
changeGroupMmsSettings(true);
}
});
final boolean mmsEnabled = BuglePrefs.getSubscriptionPrefs(mSubId).getBoolean( final boolean mmsEnabled = BuglePrefs.getSubscriptionPrefs(mSubId).getBoolean(
mContext.getString(R.string.group_mms_pref_key), mContext.getString(R.string.group_mms_pref_key),
mContext.getResources().getBoolean(R.bool.group_mms_pref_default)); mContext.getResources().getBoolean(R.bool.group_mms_pref_default));
@@ -125,12 +125,9 @@ public class PerSubscriptionSettingsActivity extends BugleActionBarActivity {
// is being sent, making sure we will have a self number for group mms. // is being sent, making sure we will have a self number for group mms.
mmsCategory.removePreference(mGroupMmsPreference); mmsCategory.removePreference(mGroupMmsPreference);
} else { } else {
mGroupMmsPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { mGroupMmsPreference.setOnPreferenceClickListener(pref -> {
@Override
public boolean onPreferenceClick(Preference pref) {
GroupMmsSettingDialog.showDialog(getActivity(), mSubId); GroupMmsSettingDialog.showDialog(getActivity(), mSubId);
return true; return true;
}
}); });
updateGroupMmsPrefSummary(); updateGroupMmsPrefSummary();
} }
@@ -27,7 +27,6 @@ import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
@@ -155,9 +154,7 @@ public class SettingsActivity extends BugleActionBarActivity {
} else { } else {
subtitleTextView.setVisibility(View.GONE); subtitleTextView.setVisibility(View.GONE);
} }
itemView.setOnClickListener(new OnClickListener() { itemView.setOnClickListener(view -> {
@Override
public void onClick(View view) {
switch (item.getType()) { switch (item.getType()) {
case SettingsItem.TYPE_GENERAL_SETTINGS: case SettingsItem.TYPE_GENERAL_SETTINGS:
UIIntents.get().launchApplicationSettingsActivity(getActivity(), UIIntents.get().launchApplicationSettingsActivity(getActivity(),
@@ -173,7 +170,6 @@ public class SettingsActivity extends BugleActionBarActivity {
Assert.fail("unrecognized setting type!"); Assert.fail("unrecognized setting type!");
break; break;
} }
}
}); });
return itemView; return itemView;
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -55,22 +56,12 @@ public class AttachmentGridItemView extends FrameLayout {
super.onFinishInflate(); super.onFinishInflate();
mAttachmentViewContainer = (FrameLayout) findViewById(R.id.attachment_container); mAttachmentViewContainer = (FrameLayout) findViewById(R.id.attachment_container);
mCheckBox = (CheckBox) findViewById(R.id.checkbox); mCheckBox = (CheckBox) findViewById(R.id.checkbox);
mCheckBox.setOnClickListener(new OnClickListener() { mCheckBox.setOnClickListener(v -> mHostInterface.onItemCheckedChanged(
@Override AttachmentGridItemView.this, mAttachmentData));
public void onClick(final View v) { setOnClickListener(v -> mHostInterface.onItemClicked(AttachmentGridItemView.this,
mHostInterface.onItemCheckedChanged(AttachmentGridItemView.this, mAttachmentData); mAttachmentData));
} addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight,
}); oldBottom) -> {
setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
mHostInterface.onItemClicked(AttachmentGridItemView.this, mAttachmentData);
}
});
addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
// Enlarge the clickable region for the checkbox. // Enlarge the clickable region for the checkbox.
final int touchAreaIncrease = getResources().getDimensionPixelOffset( final int touchAreaIncrease = getResources().getDimensionPixelOffset(
R.dimen.attachment_grid_checkbox_area_increase); R.dimen.attachment_grid_checkbox_area_increase);
@@ -78,7 +69,6 @@ public class AttachmentGridItemView extends FrameLayout {
mCheckBox.getHitRect(region); mCheckBox.getHitRect(region);
region.inset(-touchAreaIncrease, -touchAreaIncrease); region.inset(-touchAreaIncrease, -touchAreaIncrease);
setTouchDelegate(new TouchDelegate(region, mCheckBox)); setTouchDelegate(new TouchDelegate(region, mCheckBox));
}
}); });
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -36,7 +37,6 @@ import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.android.messaging.R; import com.android.messaging.R;
@@ -182,12 +182,7 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData
mToolbar = (Toolbar) view.findViewById(R.id.toolbar); mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_light); mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_light);
mToolbar.setNavigationContentDescription(R.string.back); mToolbar.setNavigationContentDescription(R.string.back);
mToolbar.setNavigationOnClickListener(new OnClickListener() { mToolbar.setNavigationOnClickListener(v -> mHost.onBackButtonPressed());
@Override
public void onClick(final View v) {
mHost.onBackButtonPressed();
}
});
mToolbar.inflateMenu(R.menu.compose_menu); mToolbar.inflateMenu(R.menu.compose_menu);
mToolbar.setOnMenuItemClickListener(this); mToolbar.setOnMenuItemClickListener(this);
@@ -325,14 +320,11 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData
// showImeKeyboard() won't work until the layout is ready, so wait until layout is complete // showImeKeyboard() won't work until the layout is ready, so wait until layout is complete
// before showing the soft keyboard. // before showing the soft keyboard.
UiUtils.doOnceAfterLayoutChange(mRootView, new Runnable() { UiUtils.doOnceAfterLayoutChange(mRootView, () -> {
@Override
public void run() {
final Activity activity = getActivity(); final Activity activity = getActivity();
if (activity != null) { if (activity != null) {
ImeUtil.get().showImeKeyboard(activity, mRecipientTextView); ImeUtil.get().showImeKeyboard(activity, mRecipientTextView);
} }
}
}); });
mRecipientTextView.invalidate(); mRecipientTextView.invalidate();
} }
@@ -541,19 +533,13 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData
mCustomHeaderViewPager.animate().alpha(show ? 1F : 0F) mCustomHeaderViewPager.animate().alpha(show ? 1F : 0F)
.setStartDelay(!show ? UiUtils.COMPOSE_TRANSITION_DURATION : 0) .setStartDelay(!show ? UiUtils.COMPOSE_TRANSITION_DURATION : 0)
.withStartAction(new Runnable() { .withStartAction(() -> {
@Override
public void run() {
mCustomHeaderViewPager.setVisibility(View.VISIBLE); mCustomHeaderViewPager.setVisibility(View.VISIBLE);
mCustomHeaderViewPager.setAlpha(show ? 0F : 1F); mCustomHeaderViewPager.setAlpha(show ? 0F : 1F);
}
}) })
.withEndAction(new Runnable() { .withEndAction(() -> {
@Override
public void run() {
mCustomHeaderViewPager.setVisibility(show ? View.VISIBLE : View.GONE); mCustomHeaderViewPager.setVisibility(show ? View.VISIBLE : View.GONE);
mCustomHeaderViewPager.setAlpha(1F); mCustomHeaderViewPager.setAlpha(1F);
}
}); });
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -59,9 +60,7 @@ public class ContactRecipientPhotoManager implements PhotoManager {
public void populatePhotoBytesAsync(final RecipientEntry entry, public void populatePhotoBytesAsync(final RecipientEntry entry,
final PhotoManagerCallback callback) { final PhotoManagerCallback callback) {
// Post all media resource request to the main thread. // Post all media resource request to the main thread.
ThreadUtil.getMainThreadHandler().post(new Runnable() { ThreadUtil.getMainThreadHandler().post(() -> {
@Override
public void run() {
final Uri avatarUri = AvatarUriUtil.createAvatarUri( final Uri avatarUri = AvatarUriUtil.createAvatarUri(
ParticipantData.getFromRecipientEntry(entry)); ParticipantData.getFromRecipientEntry(entry));
final AvatarRequestDescriptor descriptor = final AvatarRequestDescriptor descriptor =
@@ -90,7 +89,6 @@ public class ContactRecipientPhotoManager implements PhotoManager {
req.bind(IMAGE_BYTES_REQUEST_STATIC_BINDING_ID); req.bind(IMAGE_BYTES_REQUEST_STATIC_BINDING_ID);
Factory.get().getMediaResourceManager().requestMediaResourceAsync(req); Factory.get().getMediaResourceManager().requestMediaResourceAsync(req);
}
}); });
} }
} }
@@ -51,7 +51,6 @@ import com.android.messaging.datamodel.data.ConversationData.ConversationDataLis
import com.android.messaging.datamodel.data.ConversationData.SimpleConversationDataListener; import com.android.messaging.datamodel.data.ConversationData.SimpleConversationDataListener;
import com.android.messaging.datamodel.data.DraftMessageData; import com.android.messaging.datamodel.data.DraftMessageData;
import com.android.messaging.datamodel.data.DraftMessageData.CheckDraftForSendTask; import com.android.messaging.datamodel.data.DraftMessageData.CheckDraftForSendTask;
import com.android.messaging.datamodel.data.DraftMessageData.CheckDraftTaskCallback;
import com.android.messaging.datamodel.data.DraftMessageData.DraftMessageDataListener; import com.android.messaging.datamodel.data.DraftMessageData.DraftMessageDataListener;
import com.android.messaging.datamodel.data.MessageData; import com.android.messaging.datamodel.data.MessageData;
import com.android.messaging.datamodel.data.MessagePartData; import com.android.messaging.datamodel.data.MessagePartData;
@@ -197,21 +196,15 @@ public class ComposeMessageView extends LinearLayout
R.id.compose_message_text); R.id.compose_message_text);
mComposeEditText.setOnEditorActionListener(this); mComposeEditText.setOnEditorActionListener(this);
mComposeEditText.addTextChangedListener(this); mComposeEditText.addTextChangedListener(this);
mComposeEditText.setOnFocusChangeListener(new OnFocusChangeListener() { mComposeEditText.setOnFocusChangeListener((v, hasFocus) -> {
@Override
public void onFocusChange(final View v, final boolean hasFocus) {
if (v == mComposeEditText && hasFocus) { if (v == mComposeEditText && hasFocus) {
mHost.onComposeEditTextFocused(); mHost.onComposeEditTextFocused();
} }
}
}); });
mComposeEditText.setOnClickListener(new View.OnClickListener() { mComposeEditText.setOnClickListener(arg0 -> {
@Override
public void onClick(View arg0) {
if (mHost.shouldHideAttachmentsWhenSimSelectorShown()) { if (mHost.shouldHideAttachmentsWhenSimSelectorShown()) {
hideSimSelector(); hideSimSelector();
} }
}
}); });
// onFinishInflate() is called before self is loaded from db. We set the default text // onFinishInflate() is called before self is loaded from db. We set the default text
@@ -221,17 +214,12 @@ public class ComposeMessageView extends LinearLayout
.getMaxTextLimit()) }); .getMaxTextLimit()) });
mSelfSendIcon = (SimIconView) findViewById(R.id.self_send_icon); mSelfSendIcon = (SimIconView) findViewById(R.id.self_send_icon);
mSelfSendIcon.setOnClickListener(new OnClickListener() { mSelfSendIcon.setOnClickListener(v -> {
@Override
public void onClick(View v) {
boolean shown = mInputManager.toggleSimSelector(true /* animate */, boolean shown = mInputManager.toggleSimSelector(true /* animate */,
getSelfSubscriptionListEntry()); getSelfSubscriptionListEntry());
hideAttachmentsWhenShowingSims(shown); hideAttachmentsWhenShowingSims(shown);
}
}); });
mSelfSendIcon.setOnLongClickListener(new OnLongClickListener() { mSelfSendIcon.setOnLongClickListener(v -> {
@Override
public boolean onLongClick(final View v) {
if (mHost.shouldShowSubjectEditor()) { if (mHost.shouldShowSubjectEditor()) {
showSubjectEditor(); showSubjectEditor();
} else { } else {
@@ -240,7 +228,6 @@ public class ComposeMessageView extends LinearLayout
hideAttachmentsWhenShowingSims(shown); hideAttachmentsWhenShowingSims(shown);
} }
return true; return true;
}
}); });
mComposeSubjectText = (PlainTextEditText) findViewById( mComposeSubjectText = (PlainTextEditText) findViewById(
@@ -255,27 +242,18 @@ public class ComposeMessageView extends LinearLayout
.getMaxSubjectLength())}); .getMaxSubjectLength())});
mDeleteSubjectButton = (ImageButton) findViewById(R.id.delete_subject_button); mDeleteSubjectButton = (ImageButton) findViewById(R.id.delete_subject_button);
mDeleteSubjectButton.setOnClickListener(new OnClickListener() { mDeleteSubjectButton.setOnClickListener(clickView -> {
@Override
public void onClick(final View clickView) {
hideSubjectEditor(); hideSubjectEditor();
mComposeSubjectText.setText(null); mComposeSubjectText.setText(null);
mBinding.getData().setMessageSubject(null); mBinding.getData().setMessageSubject(null);
}
}); });
mSubjectView = findViewById(R.id.subject_view); mSubjectView = findViewById(R.id.subject_view);
mSendButton = (ImageButton) findViewById(R.id.send_message_button); mSendButton = (ImageButton) findViewById(R.id.send_message_button);
mSendButton.setOnClickListener(new OnClickListener() { mSendButton.setOnClickListener(clickView ->
@Override sendMessageInternal(true /* checkMessageSize */));
public void onClick(final View clickView) { mSendButton.setOnLongClickListener(arg0 -> {
sendMessageInternal(true /* checkMessageSize */);
}
});
mSendButton.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(final View arg0) {
boolean shown = mInputManager.toggleSimSelector(true /* animate */, boolean shown = mInputManager.toggleSimSelector(true /* animate */,
getSelfSubscriptionListEntry()); getSelfSubscriptionListEntry());
hideAttachmentsWhenShowingSims(shown); hideAttachmentsWhenShowingSims(shown);
@@ -283,7 +261,6 @@ public class ComposeMessageView extends LinearLayout
showSubjectEditor(); showSubjectEditor();
} }
return true; return true;
}
}); });
mSendButton.setAccessibilityDelegate(new AccessibilityDelegate() { mSendButton.setAccessibilityDelegate(new AccessibilityDelegate() {
@Override @Override
@@ -306,12 +283,9 @@ public class ComposeMessageView extends LinearLayout
mAttachMediaButton = mAttachMediaButton =
(ImageButton) findViewById(R.id.attach_media_button); (ImageButton) findViewById(R.id.attach_media_button);
mAttachMediaButton.setOnClickListener(new View.OnClickListener() { mAttachMediaButton.setOnClickListener(clickView -> {
@Override
public void onClick(final View clickView) {
// Showing the media picker is treated as starting to compose the message. // Showing the media picker is treated as starting to compose the message.
mInputManager.showHideMediaPicker(true /* show */, true /* animate */); mInputManager.showHideMediaPicker(true /* show */, true /* animate */);
}
}); });
mAttachmentPreview = (AttachmentPreview) findViewById(R.id.attachment_draft_view); mAttachmentPreview = (AttachmentPreview) findViewById(R.id.attachment_draft_view);
@@ -394,9 +368,7 @@ public class ComposeMessageView extends LinearLayout
mBinding.getData().setMessageSubject(subject); mBinding.getData().setMessageSubject(subject);
// Asynchronously check the draft against various requirements before sending. // Asynchronously check the draft against various requirements before sending.
mBinding.getData().checkDraftForAction(checkMessageSize, mBinding.getData().checkDraftForAction(checkMessageSize,
mHost.getConversationSelfSubId(), new CheckDraftTaskCallback() { mHost.getConversationSelfSubId(), (data, result) -> {
@Override
public void onDraftChecked(DraftMessageData data, int result) {
mBinding.ensureBound(data); mBinding.ensureBound(data);
switch (result) { switch (result) {
case CheckDraftForSendTask.RESULT_PASSED: case CheckDraftForSendTask.RESULT_PASSED:
@@ -446,17 +418,10 @@ public class ComposeMessageView extends LinearLayout
default: default:
break; break;
} }
}
}, mBinding); }, mBinding);
} else { } else {
mHost.warnOfMissingActionConditions(true /*sending*/, mHost.warnOfMissingActionConditions(true /*sending*/, () ->
new Runnable() { sendMessageInternal(checkMessageSize));
@Override
public void run() {
sendMessageInternal(checkMessageSize);
}
});
} }
} }
@@ -110,12 +110,9 @@ public class ConversationFastScroller extends RecyclerView.OnScrollListener impl
private AnimatorSet mHideAnimation; private AnimatorSet mHideAnimation;
private ObjectAnimator mHidePreviewAnimation; private ObjectAnimator mHidePreviewAnimation;
private final Runnable mHideTrackRunnable = new Runnable() { private final Runnable mHideTrackRunnable = () -> {
@Override
public void run() {
hide(true /* animate */); hide(true /* animate */);
mPendingHide = false; mPendingHide = false;
}
}; };
private ConversationFastScroller(RecyclerView rv, int position) { private ConversationFastScroller(RecyclerView rv, int position) {
@@ -28,10 +28,6 @@ import android.content.BroadcastReceiver;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.res.Configuration; import android.content.res.Configuration;
@@ -420,20 +416,14 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
mAdapter = new ConversationMessageAdapter(getActivity(), null, this, mAdapter = new ConversationMessageAdapter(getActivity(), null, this,
null, null,
// Sets the item click listener on the Recycler item views. // Sets the item click listener on the Recycler item views.
new View.OnClickListener() { v -> {
@Override
public void onClick(final View v) {
final ConversationMessageView messageView = (ConversationMessageView) v; final ConversationMessageView messageView = (ConversationMessageView) v;
handleMessageClick(messageView); handleMessageClick(messageView);
}
}, },
new View.OnLongClickListener() { view -> {
@Override
public boolean onLongClick(final View view) {
selectMessage((ConversationMessageView) view); selectMessage((ConversationMessageView) view);
return true; return true;
} }
}
); );
} }
@@ -555,22 +545,16 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
view.setAlpha(0); view.setAlpha(0);
mPopupTransitionAnimation = new PopupTransitionAnimation(startRect, view); mPopupTransitionAnimation = new PopupTransitionAnimation(startRect, view);
mPopupTransitionAnimation.setOnStartCallback(new Runnable() { mPopupTransitionAnimation.setOnStartCallback(() -> {
@Override
public void run() {
final int startWidth = composeBubbleRect.width(); final int startWidth = composeBubbleRect.width();
attachmentView.onMessageAnimationStart(); attachmentView.onMessageAnimationStart();
messageBubble.kickOffMorphAnimation(startWidth, messageBubble.kickOffMorphAnimation(startWidth,
messageBubble.findViewById(R.id.message_text_and_info) messageBubble.findViewById(R.id.message_text_and_info)
.getMeasuredWidth()); .getMeasuredWidth());
}
}); });
mPopupTransitionAnimation.setOnStopCallback(new Runnable() { mPopupTransitionAnimation.setOnStopCallback(() -> {
@Override
public void run() {
view.setAlpha(1); view.setAlpha(1);
dispatchAddFinished(holder); dispatchAddFinished(holder);
}
}); });
mPopupTransitionAnimation.startAfterLayoutComplete(); mPopupTransitionAnimation.startAfterLayoutComplete();
mAddAnimations.add(holder); mAddAnimations.add(holder);
@@ -827,13 +811,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
.setTitle(getResources().getQuantityString( .setTitle(getResources().getQuantityString(
R.plurals.delete_conversations_confirmation_dialog_title, 1)) R.plurals.delete_conversations_confirmation_dialog_title, 1))
.setPositiveButton(R.string.delete_conversation_confirmation_button, .setPositiveButton(R.string.delete_conversation_confirmation_button,
new DialogInterface.OnClickListener() { (dialog, button) -> deleteConversation())
@Override
public void onClick(final DialogInterface dialog,
final int button) {
deleteConversation();
}
})
.setNegativeButton(R.string.delete_conversation_decline_button, null) .setNegativeButton(R.string.delete_conversation_decline_button, null)
.show(); .show();
} else { } else {
@@ -894,12 +872,9 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
UiUtils.showSnackBarWithCustomAction(getActivity(), UiUtils.showSnackBarWithCustomAction(getActivity(),
getView().getRootView(), getView().getRootView(),
getString(R.string.in_conversation_notify_new_message_text), getString(R.string.in_conversation_notify_new_message_text),
SnackBar.Action.createCustomAction(new Runnable() { SnackBar.Action.createCustomAction(() -> {
@Override
public void run() {
scrollToBottom(true /* smoothScroll */); scrollToBottom(true /* smoothScroll */);
mComposeMessageView.hideAllComposeInputs(false /* animate */); mComposeMessageView.hideAllComposeInputs(false /* animate */);
}
}, },
getString(R.string.in_conversation_notify_new_message_action)), getString(R.string.in_conversation_notify_new_message_action)),
null /* interactions */, null /* interactions */,
@@ -1036,13 +1011,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
LogUtil.w(LogUtil.BUGLE_TAG, "Message can't be sent: conv participants not loaded"); LogUtil.w(LogUtil.BUGLE_TAG, "Message can't be sent: conv participants not loaded");
} }
} else { } else {
warnOfMissingActionConditions(true /*sending*/, warnOfMissingActionConditions(true /*sending*/, () -> sendMessage(message));
new Runnable() {
@Override
public void run() {
sendMessage(message);
}
});
} }
} }
@@ -1137,14 +1106,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
mBinding.getData().resendMessage(mBinding, messageId); mBinding.getData().resendMessage(mBinding, messageId);
} }
} else { } else {
warnOfMissingActionConditions(true /*sending*/, warnOfMissingActionConditions(true /*sending*/, () -> retrySend(messageId));
new Runnable() {
@Override
public void run() {
retrySend(messageId);
}
});
} }
} }
@@ -1154,12 +1116,8 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
.setTitle(R.string.delete_message_confirmation_dialog_title) .setTitle(R.string.delete_message_confirmation_dialog_title)
.setMessage(R.string.delete_message_confirmation_dialog_text) .setMessage(R.string.delete_message_confirmation_dialog_text)
.setPositiveButton(R.string.delete_message_confirmation_button, .setPositiveButton(R.string.delete_message_confirmation_button,
new OnClickListener() { (dialog, which) ->
@Override mBinding.getData().deleteMessage(mBinding, messageId))
public void onClick(final DialogInterface dialog, final int which) {
mBinding.getData().deleteMessage(mBinding, messageId);
}
})
.setNegativeButton(android.R.string.cancel, null); .setNegativeButton(android.R.string.cancel, null);
builder.setOnDismissListener(dialog -> mHost.dismissActionMode()); builder.setOnDismissListener(dialog -> mHost.dismissActionMode());
builder.create().show(); builder.create().show();
@@ -1506,19 +1464,11 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
} else { } else {
builder.setMessage(R.string.attachment_limit_reached_dialog_message_when_sending) builder.setMessage(R.string.attachment_limit_reached_dialog_message_when_sending)
.setNegativeButton(R.string.attachment_limit_reached_send_anyway, .setNegativeButton(R.string.attachment_limit_reached_send_anyway,
new OnClickListener() { (dialog, which) ->
@Override composeMessageView.sendMessageIgnoreMessageSizeLimit());
public void onClick(final DialogInterface dialog,
final int which) {
composeMessageView.sendMessageIgnoreMessageSizeLimit();
} }
}); builder.setPositiveButton(android.R.string.ok, (dialog, which) ->
} showAttachmentChooser(conversationId, activity));
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
showAttachmentChooser(conversationId, activity);
}});
} else { } else {
builder.setMessage(R.string.attachment_limit_reached_dialog_message_when_composing) builder.setMessage(R.string.attachment_limit_reached_dialog_message_when_composing)
.setPositiveButton(android.R.string.ok, null); .setPositiveButton(android.R.string.ok, null);
@@ -1557,12 +1507,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
final LayoutInflater inflator = (LayoutInflater) final LayoutInflater inflator = (LayoutInflater)
getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
customView = inflator.inflate(R.layout.action_bar_conversation_name, null); customView = inflator.inflate(R.layout.action_bar_conversation_name, null);
customView.setOnClickListener(new View.OnClickListener() { customView.setOnClickListener(v -> onBackPressed());
@Override
public void onClick(final View v) {
onBackPressed();
}
});
actionBar.setCustomView(customView); actionBar.setCustomView(customView);
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -123,12 +124,9 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon); mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon);
mContactIconView.setOnLongClickListener(new OnLongClickListener() { mContactIconView.setOnLongClickListener(view -> {
@Override
public boolean onLongClick(final View view) {
ConversationMessageView.this.performLongClick(); ConversationMessageView.this.performLongClick();
return true; return true;
}
}); });
mMessageAttachmentsView = (LinearLayout) findViewById(R.id.message_attachments); mMessageAttachmentsView = (LinearLayout) findViewById(R.id.message_attachments);
@@ -1044,40 +1042,13 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
} }
// Sort photos in MultiAttachLayout in the same order as the ConversationImagePartsView // Sort photos in MultiAttachLayout in the same order as the ConversationImagePartsView
static final Comparator<MessagePartData> sImageComparator = new Comparator<MessagePartData>(){ static final Comparator<MessagePartData> sImageComparator =
@Override Comparator.comparing(MessagePartData::getPartId);
public int compare(final MessagePartData x, final MessagePartData y) {
return x.getPartId().compareTo(y.getPartId());
}
};
static final Predicate<MessagePartData> sVideoFilter = new Predicate<MessagePartData>() { static final Predicate<MessagePartData> sVideoFilter = MessagePartData::isVideo;
@Override static final Predicate<MessagePartData> sAudioFilter = MessagePartData::isAudio;
public boolean apply(final MessagePartData part) { static final Predicate<MessagePartData> sVCardFilter = MessagePartData::isVCard;
return part.isVideo(); static final Predicate<MessagePartData> sImageFilter = MessagePartData::isImage;
}
};
static final Predicate<MessagePartData> sAudioFilter = new Predicate<MessagePartData>() {
@Override
public boolean apply(final MessagePartData part) {
return part.isAudio();
}
};
static final Predicate<MessagePartData> sVCardFilter = new Predicate<MessagePartData>() {
@Override
public boolean apply(final MessagePartData part) {
return part.isVCard();
}
};
static final Predicate<MessagePartData> sImageFilter = new Predicate<MessagePartData>() {
@Override
public boolean apply(final MessagePartData part) {
return part.isImage();
}
};
interface AttachmentViewBinder { interface AttachmentViewBinder {
void bindView(View view, MessagePartData attachment); void bindView(View view, MessagePartData attachment);
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -48,13 +49,10 @@ abstract class ConversationSimSelector extends ConversationInput {
if (mPendingShow != null && mDataReady) { if (mPendingShow != null && mDataReady) {
final boolean show = mPendingShow.first; final boolean show = mPendingShow.first;
final boolean animate = mPendingShow.second; final boolean animate = mPendingShow.second;
ThreadUtil.getMainThreadHandler().post(new Runnable() { ThreadUtil.getMainThreadHandler().post(() -> {
@Override
public void run() {
// This will No-Op if we are no longer attached to the host. // This will No-Op if we are no longer attached to the host.
mConversationInputBase.showHideInternal(ConversationSimSelector.this, mConversationInputBase.showHideInternal(ConversationSimSelector.this,
show, animate); show, animate);
}
}); });
mPendingShow = null; mPendingShow = null;
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -19,7 +20,6 @@ import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@@ -53,19 +53,8 @@ public class EnterSelfPhoneNumberDialog extends DialogFragment {
builder.setTitle(R.string.enter_phone_number_title) builder.setTitle(R.string.enter_phone_number_title)
.setMessage(R.string.enter_phone_number_text) .setMessage(R.string.enter_phone_number_text)
.setView(mEditText) .setView(mEditText)
.setNegativeButton(android.R.string.cancel, .setNegativeButton(android.R.string.cancel, (dialog, button) -> dismiss())
new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, (dialog, button) -> {
@Override
public void onClick(final DialogInterface dialog,
final int button) {
dismiss();
}
})
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog,
final int button) {
final String newNumber = mEditText.getText().toString(); final String newNumber = mEditText.getText().toString();
dismiss(); dismiss();
if (!TextUtils.isEmpty(newNumber)) { if (!TextUtils.isEmpty(newNumber)) {
@@ -76,7 +65,6 @@ public class EnterSelfPhoneNumberDialog extends DialogFragment {
R.string R.string
.toast_after_setting_default_sms_app_for_message_send); .toast_after_setting_default_sms_app_for_message_send);
} }
}
}); });
return builder.create(); return builder.create();
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,7 +19,6 @@ package com.android.messaging.ui.conversation;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@@ -49,12 +49,7 @@ public class SimSelectorItemView extends LinearLayout {
mNameTextView = (TextView) findViewById(R.id.name); mNameTextView = (TextView) findViewById(R.id.name);
mDetailsTextView = (TextView) findViewById(R.id.details); mDetailsTextView = (TextView) findViewById(R.id.details);
mSimIconView = (SimIconView) findViewById(R.id.sim_icon); mSimIconView = (SimIconView) findViewById(R.id.sim_icon);
setOnClickListener(new OnClickListener() { setOnClickListener(v -> mHost.onSimItemClicked(mData));
@Override
public void onClick(View v) {
mHost.onSimItemClicked(mData);
}
});
} }
public void bind(final SubscriptionListEntry simEntry) { public void bind(final SubscriptionListEntry simEntry) {
@@ -64,12 +64,7 @@ public class SimSelectorView extends FrameLayout implements SimSelectorItemView.
mSimListView.setAdapter(mAdapter); mSimListView.setAdapter(mAdapter);
// Clicking anywhere outside the switcher list should dismiss. // Clicking anywhere outside the switcher list should dismiss.
setOnClickListener(new OnClickListener() { setOnClickListener(v -> showOrHide(false, true));
@Override
public void onClick(View v) {
showOrHide(false, true);
}
});
} }
public void bind(final SubscriptionListData data) { public void bind(final SubscriptionListData data) {
@@ -102,12 +97,9 @@ public class SimSelectorView extends FrameLayout implements SimSelectorItemView.
setAlpha(mShow ? 0.0f : 1.0f); setAlpha(mShow ? 0.0f : 1.0f);
animate().alpha(mShow ? 1.0f : 0.0f) animate().alpha(mShow ? 1.0f : 0.0f)
.setDuration(UiUtils.REVEAL_ANIMATION_DURATION) .setDuration(UiUtils.REVEAL_ANIMATION_DURATION)
.withEndAction(new Runnable() { .withEndAction(() -> {
@Override
public void run() {
setAlpha(1.0f); setAlpha(1.0f);
setVisibility(mShow ? VISIBLE : GONE); setVisibility(mShow ? VISIBLE : GONE);
}
}); });
} else { } else {
setVisibility(mShow ? VISIBLE : GONE); setVisibility(mShow ? VISIBLE : GONE);
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -19,7 +20,6 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Fragment; import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
@@ -118,13 +118,10 @@ public abstract class AbstractConversationListActivity extends BugleActionBarAc
UiUtils.showSnackBarWithCustomAction(this, UiUtils.showSnackBarWithCustomAction(this,
getWindow().getDecorView().getRootView(), getWindow().getDecorView().getRootView(),
getString(R.string.requires_default_sms_app), getString(R.string.requires_default_sms_app),
SnackBar.Action.createCustomAction(new Runnable() { SnackBar.Action.createCustomAction(() -> {
@Override
public void run() {
final Intent intent = final Intent intent =
UIIntents.get().getChangeDefaultSmsAppIntent(activity); UIIntents.get().getChangeDefaultSmsAppIntent(activity);
startActivityForResult(intent, REQUEST_SET_DEFAULT_SMS_APP); startActivityForResult(intent, REQUEST_SET_DEFAULT_SMS_APP);
}
}, },
getString(R.string.requires_default_sms_change_button)), getString(R.string.requires_default_sms_change_button)),
null /* interactions */, null /* interactions */,
@@ -137,17 +134,13 @@ public abstract class AbstractConversationListActivity extends BugleActionBarAc
R.plurals.delete_conversations_confirmation_dialog_title, R.plurals.delete_conversations_confirmation_dialog_title,
conversations.size())) conversations.size()))
.setPositiveButton(R.string.delete_conversation_confirmation_button, .setPositiveButton(R.string.delete_conversation_confirmation_button,
new DialogInterface.OnClickListener() { (dialog, button) -> {
@Override
public void onClick(final DialogInterface dialog,
final int button) {
for (final SelectedConversation conversation : conversations) { for (final SelectedConversation conversation : conversations) {
DeleteConversationAction.deleteConversation( DeleteConversationAction.deleteConversation(
conversation.conversationId, conversation.conversationId,
conversation.timestamp); conversation.timestamp);
} }
exitMultiSelectState(); exitMultiSelectState();
}
}) })
.setNegativeButton(R.string.delete_conversation_decline_button, null) .setNegativeButton(R.string.delete_conversation_decline_button, null)
.show(); .show();
@@ -167,9 +160,7 @@ public abstract class AbstractConversationListActivity extends BugleActionBarAc
} }
} }
final Runnable undoRunnable = new Runnable() { final Runnable undoRunnable = () -> {
@Override
public void run() {
for (final String conversationId : conversationIds) { for (final String conversationId : conversationIds) {
if (isToArchive) { if (isToArchive) {
UpdateConversationArchiveStatusAction.unarchiveConversation(conversationId); UpdateConversationArchiveStatusAction.unarchiveConversation(conversationId);
@@ -177,7 +168,6 @@ public abstract class AbstractConversationListActivity extends BugleActionBarAc
UpdateConversationArchiveStatusAction.archiveConversation(conversationId); UpdateConversationArchiveStatusAction.archiveConversation(conversationId);
} }
} }
}
}; };
final int textId = final int textId =
@@ -211,9 +201,7 @@ public abstract class AbstractConversationListActivity extends BugleActionBarAc
conversation.otherParticipantNormalizedDestination)) conversation.otherParticipantNormalizedDestination))
.setMessage(res.getString(R.string.block_confirmation_message)) .setMessage(res.getString(R.string.block_confirmation_message))
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, (arg0, arg1) -> {
@Override
public void onClick(final DialogInterface arg0, final int arg1) {
final Context context = AbstractConversationListActivity.this; final Context context = AbstractConversationListActivity.this;
final View listView = findViewById(android.R.id.list); final View listView = findViewById(android.R.id.list);
final List<SnackBarInteraction> interactions = final List<SnackBarInteraction> interactions =
@@ -223,15 +211,11 @@ public abstract class AbstractConversationListActivity extends BugleActionBarAc
new UpdateDestinationBlockedActionSnackBar( new UpdateDestinationBlockedActionSnackBar(
context, listView, null /* undoRunnable */, context, listView, null /* undoRunnable */,
interactions); interactions);
final Runnable undoRunnable = new Runnable() { final Runnable undoRunnable = () ->
@Override
public void run() {
UpdateDestinationBlockedAction.updateDestinationBlocked( UpdateDestinationBlockedAction.updateDestinationBlocked(
conversation.otherParticipantNormalizedDestination, false, conversation.otherParticipantNormalizedDestination, false,
conversation.conversationId, conversation.conversationId,
undoListener); undoListener);
}
};
final UpdateDestinationBlockedAction.UpdateDestinationBlockedActionListener final UpdateDestinationBlockedAction.UpdateDestinationBlockedActionListener
listener = new UpdateDestinationBlockedActionSnackBar( listener = new UpdateDestinationBlockedActionSnackBar(
context, listView, undoRunnable, interactions); context, listView, undoRunnable, interactions);
@@ -240,7 +224,6 @@ public abstract class AbstractConversationListActivity extends BugleActionBarAc
conversation.conversationId, conversation.conversationId,
listener); listener);
exitMultiSelectState(); exitMultiSelectState();
}
}) })
.create() .create()
.show(); .show();
@@ -35,7 +35,6 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams; import android.view.ViewGroup.MarginLayoutParams;
import android.view.ViewPropertyAnimator; import android.view.ViewPropertyAnimator;
@@ -229,12 +228,8 @@ public class ConversationListFragment extends Fragment implements ConversationLi
mStartNewConversationButton.setVisibility(View.GONE); mStartNewConversationButton.setVisibility(View.GONE);
} else { } else {
mStartNewConversationButton.setVisibility(View.VISIBLE); mStartNewConversationButton.setVisibility(View.VISIBLE);
mStartNewConversationButton.setOnClickListener(new OnClickListener() { mStartNewConversationButton.setOnClickListener(clickView ->
@Override mHost.onCreateConversationClick());
public void onClick(final View clickView) {
mHost.onCreateConversationClick();
}
});
} }
ViewCompat.setTransitionName(mStartNewConversationButton, BugleAnimationTags.TAG_FABICON); ViewCompat.setTransitionName(mStartNewConversationButton, BugleAnimationTags.TAG_FABICON);
@@ -415,12 +410,9 @@ public class ConversationListFragment extends Fragment implements ConversationLi
} }
public ViewPropertyAnimator showFab() { public ViewPropertyAnimator showFab() {
return getNormalizedFabAnimator().translationX(0).withEndAction(new Runnable() { return getNormalizedFabAnimator().translationX(0).withEndAction(() -> {
@Override
public void run() {
// Re-enable clicks after the animation. // Re-enable clicks after the animation.
mStartNewConversationButton.setEnabled(true); mStartNewConversationButton.setEnabled(true);
}
}); });
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -552,12 +553,8 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
return; return;
} }
UpdateConversationArchiveStatusAction.archiveConversation(conversationId); UpdateConversationArchiveStatusAction.archiveConversation(conversationId);
final Runnable undoRunnable = new Runnable() { final Runnable undoRunnable = () ->
@Override
public void run() {
UpdateConversationArchiveStatusAction.unarchiveConversation(conversationId); UpdateConversationArchiveStatusAction.unarchiveConversation(conversationId);
}
};
final String message = getResources().getString(R.string.archived_toast_message, 1); final String message = getResources().getString(R.string.archived_toast_message, 1);
UiUtils.showSnackBar(getContext(), getRootView(), message, undoRunnable, UiUtils.showSnackBar(getContext(), getRootView(), message, undoRunnable,
SnackBar.Action.SNACK_BAR_UNDO, SnackBar.Action.SNACK_BAR_UNDO,
@@ -22,7 +22,6 @@ import android.app.AlertDialog.Builder;
import android.app.Dialog; import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.database.Cursor; import android.database.Cursor;
import android.os.Bundle; import android.os.Bundle;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@@ -92,12 +91,9 @@ public class ShareIntentFragment extends DialogFragment implements ConversationL
final Bundle arguments = getArguments(); final Bundle arguments = getArguments();
if (arguments == null || !arguments.getBoolean(HIDE_NEW_CONVERSATION_BUTTON_KEY)) { if (arguments == null || !arguments.getBoolean(HIDE_NEW_CONVERSATION_BUTTON_KEY)) {
dialogBuilder.setPositiveButton(R.string.share_new_message, new OnClickListener() { dialogBuilder.setPositiveButton(R.string.share_new_message, (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
mDismissed = true; mDismissed = true;
mHost.onCreateConversationClick(); mHost.onCreateConversationClick();
}
}); });
} }
return dialogBuilder.setNegativeButton(R.string.share_cancel, null) return dialogBuilder.setNegativeButton(R.string.share_cancel, null)
@@ -21,7 +21,6 @@ import android.app.AlertDialog;
import android.app.Fragment; import android.app.Fragment;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.database.Cursor; import android.database.Cursor;
@@ -156,14 +155,10 @@ public class PeopleAndOptionsFragment extends Fragment
item.getOtherParticipant().getDisplayDestination())) item.getOtherParticipant().getDisplayDestination()))
.setMessage(res.getString(R.string.block_confirmation_message)) .setMessage(res.getString(R.string.block_confirmation_message))
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, .setPositiveButton(android.R.string.ok, (arg0, arg1) -> {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
mBinding.getData().setDestinationBlocked(mBinding, true); mBinding.getData().setDestinationBlocked(mBinding, true);
activity.setResult(ConversationActivity.FINISH_RESULT_CODE); activity.setResult(ConversationActivity.FINISH_RESULT_CODE);
activity.finish(); activity.finish();
}
}) })
.create() .create()
.show(); .show();
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,7 +21,6 @@ import android.database.Cursor;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@@ -55,12 +55,7 @@ public class PeopleOptionsItemView extends LinearLayout {
@Override @Override
protected void onFinishInflate () { protected void onFinishInflate () {
mTitle = (TextView) findViewById(R.id.title); mTitle = (TextView) findViewById(R.id.title);
setOnClickListener(new OnClickListener() { setOnClickListener(v -> mHostInterface.onOptionsItemViewClicked(mData));
@Override
public void onClick(final View v) {
mHostInterface.onOptionsItemViewClicked(mData);
}
});
} }
public void bind(final Cursor cursor, final int columnIndex, ParticipantData otherParticipant, public void bind(final Cursor cursor, final int columnIndex, ParticipantData otherParticipant,
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,7 +19,6 @@ package com.android.messaging.ui.debug;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnShowListener;
import android.text.InputType; import android.text.InputType;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
@@ -115,14 +115,11 @@ public class DebugMmsConfigItemView extends LinearLayout implements OnClickListe
.setPositiveButton(android.R.string.ok, this) .setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.create(); .create();
dialog.setOnShowListener(new OnShowListener() { dialog.setOnShowListener(dialog1 -> {
@Override
public void onShow(DialogInterface dialog) {
mEditText.requestFocus(); mEditText.requestFocus();
mEditText.selectAll(); mEditText.selectAll();
((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE)) ((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE))
.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); .toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
}
}); });
dialog.show(); dialog.show();
} }
@@ -29,7 +29,6 @@ import android.os.Environment;
import android.telephony.SmsMessage; import android.telephony.SmsMessage;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
@@ -113,16 +112,13 @@ public class DebugSmsMmsFromDumpFileDialogFragment extends DialogFragment {
final String file = getItem(position); final String file = getItem(position);
actionItemView.setText(file); actionItemView.setText(file);
actionItemView.setOnClickListener(new OnClickListener() { actionItemView.setOnClickListener(view1 -> {
@Override
public void onClick(final View view) {
dismiss(); dismiss();
if (ACTION_LOAD.equals(mAction)) { if (ACTION_LOAD.equals(mAction)) {
receiveFromDumpFile(file); receiveFromDumpFile(file);
} else if (ACTION_EMAIL.equals(mAction)) { } else if (ACTION_EMAIL.equals(mAction)) {
emailDumpFile(file); emailDumpFile(file);
} }
}
}); });
return actionItemView; return actionItemView;
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -121,9 +122,7 @@ public class AudioRecordView extends FrameLayout implements
mHintTextView = (TextView) findViewById(R.id.hint_text); mHintTextView = (TextView) findViewById(R.id.hint_text);
mTimerTextView = (PausableChronometer) findViewById(R.id.timer_text); mTimerTextView = (PausableChronometer) findViewById(R.id.timer_text);
mSoundLevels.setLevelSource(mMediaRecorder.getLevelSource()); mSoundLevels.setLevelSource(mMediaRecorder.getLevelSource());
mRecordButton.setOnTouchListener(new OnTouchListener() { mRecordButton.setOnTouchListener((v, event) -> {
@Override
public boolean onTouch(final View v, final MotionEvent event) {
final int action = event.getActionMasked(); final int action = event.getActionMasked();
switch (action) { switch (action) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
@@ -137,7 +136,6 @@ public class AudioRecordView extends FrameLayout implements
return false; return false;
} }
return false; return false;
}
}); });
} }
@@ -242,9 +240,7 @@ public class AudioRecordView extends FrameLayout implements
boolean onRecordButtonTouchDown() { boolean onRecordButtonTouchDown() {
if (!mMediaRecorder.isRecording() && mCurrentMode == MODE_IDLE) { if (!mMediaRecorder.isRecording() && mCurrentMode == MODE_IDLE) {
setMode(MODE_STARTING); setMode(MODE_STARTING);
playAudioStartSound(new OnCompletionListener() { playAudioStartSound(() -> {
@Override
public void onCompletion() {
// Double-check the current mode before recording since the user may have // Double-check the current mode before recording since the user may have
// lifted finger from the button before the beeping sound is played through. // lifted finger from the button before the beeping sound is played through.
final int maxSize = MmsConfig.get(mHostInterface.getConversationSelfSubId()) final int maxSize = MmsConfig.get(mHostInterface.getConversationSelfSubId())
@@ -254,7 +250,6 @@ public class AudioRecordView extends FrameLayout implements
AudioRecordView.this, maxSize)) { AudioRecordView.this, maxSize)) {
setMode(MODE_RECORDING); setMode(MODE_RECORDING);
} }
}
}); });
mAudioRecordStartTimeMillis = System.currentTimeMillis(); mAudioRecordStartTimeMillis = System.currentTimeMillis();
return true; return true;
@@ -270,25 +265,17 @@ public class AudioRecordView extends FrameLayout implements
// "tap+hold" to record audio. // "tap+hold" to record audio.
final Uri outputUri = stopRecording(); final Uri outputUri = stopRecording();
if (outputUri != null) { if (outputUri != null) {
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(() ->
@Override
public void run() {
Factory.get().getApplicationContext().getContentResolver().delete( Factory.get().getApplicationContext().getContentResolver().delete(
outputUri, null, null); outputUri, null, null));
}
});
} }
setMode(MODE_IDLE); setMode(MODE_IDLE);
mHintTextView.setTypeface(null, Typeface.BOLD); mHintTextView.setTypeface(null, Typeface.BOLD);
} else if (isRecording()) { } else if (isRecording()) {
// Record for some extra time to ensure the ending part is saved. // Record for some extra time to ensure the ending part is saved.
setMode(MODE_STOPPING); setMode(MODE_STOPPING);
ThreadUtil.getMainThreadHandler().postDelayed(new Runnable() { ThreadUtil.getMainThreadHandler().postDelayed(this::onFinishedRecording,
@Override AUDIO_RECORD_ENDING_BUFFER_MILLIS);
public void run() {
onFinishedRecording();
}
}, AUDIO_RECORD_ENDING_BUFFER_MILLIS);
} else { } else {
setMode(MODE_IDLE); setMode(MODE_IDLE);
} }
@@ -35,7 +35,6 @@ import android.util.DisplayMetrics;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.OrientationEventListener; import android.view.OrientationEventListener;
import android.view.Surface; import android.view.Surface;
import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import com.android.messaging.datamodel.data.DraftMessageData.DraftMessageSubscriptionDataProvider; import com.android.messaging.datamodel.data.DraftMessageData.DraftMessageSubscriptionDataProvider;
@@ -268,9 +267,7 @@ class CameraManager implements FocusOverlayManager.Listener {
if (preview != null) { if (preview != null) {
Assert.isTrue(preview.isValid()); Assert.isTrue(preview.isValid());
preview.setOnTouchListener(new View.OnTouchListener() { preview.setOnTouchListener((view, motionEvent) -> {
@Override
public boolean onTouch(final View view, final MotionEvent motionEvent) {
if ((motionEvent.getActionMasked() & MotionEvent.ACTION_UP) == if ((motionEvent.getActionMasked() & MotionEvent.ACTION_UP) ==
MotionEvent.ACTION_UP) { MotionEvent.ACTION_UP) {
mFocusOverlayManager.setPreviewSize(view.getWidth(), view.getHeight()); mFocusOverlayManager.setPreviewSize(view.getWidth(), view.getHeight());
@@ -279,7 +276,6 @@ class CameraManager implements FocusOverlayManager.Listener {
(int) motionEvent.getY() + view.getTop()); (int) motionEvent.getY() + view.getTop());
} }
return true; return true;
}
}); });
} }
mCameraPreview = preview; mCameraPreview = preview;
@@ -542,9 +538,7 @@ class CameraManager implements FocusOverlayManager.Listener {
callback.onMediaFailed(null); callback.onMediaFailed(null);
return; return;
} }
final Camera.PictureCallback jpegCallback = new Camera.PictureCallback() { final Camera.PictureCallback jpegCallback = (bytes, camera) -> {
@Override
public void onPictureTaken(final byte[] bytes, final Camera camera) {
mTakingPicture = false; mTakingPicture = false;
if (mCamera != camera) { if (mCamera != camera) {
// This may happen if the camera was changed between front/back while the // This may happen if the camera was changed between front/back while the
@@ -571,7 +565,6 @@ class CameraManager implements FocusOverlayManager.Listener {
new ImagePersistTask( new ImagePersistTask(
width, height, heightPercent, bytes, mCameraPreview.getContext(), callback) width, height, heightPercent, bytes, mCameraPreview.getContext(), callback)
.executeOnThreadPool(); .executeOnThreadPool();
}
}; };
mTakingPicture = true; mTakingPicture = true;
@@ -757,12 +750,8 @@ class CameraManager implements FocusOverlayManager.Listener {
mCamera.setParameters(params); mCamera.setParameters(params);
mCameraPreview.startPreview(mCamera); mCameraPreview.startPreview(mCamera);
mCamera.startPreview(); mCamera.startPreview();
mCamera.setAutoFocusMoveCallback(new Camera.AutoFocusMoveCallback() { mCamera.setAutoFocusMoveCallback((start, camera) ->
@Override mFocusOverlayManager.onAutoFocusMoving(start));
public void onAutoFocusMoving(final boolean start, final Camera camera) {
mFocusOverlayManager.onAutoFocusMoving(start);
}
});
mFocusOverlayManager.setParameters(mCamera.getParameters()); mFocusOverlayManager.setParameters(mCamera.getParameters());
mFocusOverlayManager.setMirror(mCameraInfo.facing == CameraInfo.CAMERA_FACING_BACK); mFocusOverlayManager.setMirror(mCameraInfo.facing == CameraInfo.CAMERA_FACING_BACK);
mFocusOverlayManager.onPreviewStarted(); mFocusOverlayManager.onPreviewStarted();
@@ -830,25 +819,18 @@ class CameraManager implements FocusOverlayManager.Listener {
return; return;
} }
mMediaRecorder.setOnErrorListener(new MediaRecorder.OnErrorListener() { mMediaRecorder.setOnErrorListener((mediaRecorder, what, extra) -> {
@Override
public void onError(final MediaRecorder mediaRecorder, final int what,
final int extra) {
if (mListener != null) { if (mListener != null) {
mListener.onCameraError(ERROR_RECORDING_VIDEO, null); mListener.onCameraError(ERROR_RECORDING_VIDEO, null);
} }
restoreRequestedOrientation(); restoreRequestedOrientation();
}
}); });
mMediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() { mMediaRecorder.setOnInfoListener((mediaRecorder, what, extra) -> {
@Override
public void onInfo(final MediaRecorder mediaRecorder, final int what, final int extra) {
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED || if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED ||
what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) { what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) {
stopVideo(); stopVideo();
} }
}
}); });
try { try {
@@ -1094,12 +1076,8 @@ class CameraManager implements FocusOverlayManager.Listener {
} }
try { try {
mCamera.autoFocus(new Camera.AutoFocusCallback() { mCamera.autoFocus((success, camera) -> mFocusOverlayManager.onAutoFocus(success,
@Override false /* shutterDown */));
public void onAutoFocus(final boolean success, final Camera camera) {
mFocusOverlayManager.onAutoFocus(success, false /* shutterDown */);
}
});
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
LogUtil.e(TAG, "RuntimeException in CameraManager.autoFocus", e); LogUtil.e(TAG, "RuntimeException in CameraManager.autoFocus", e);
// If autofocus fails, the camera should have called the callback with success=false, // If autofocus fails, the camera should have called the callback with success=false,
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -24,7 +25,6 @@ import android.hardware.Camera;
import android.net.Uri; import android.net.Uri;
import android.os.SystemClock; import android.os.SystemClock;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.AlphaAnimation; import android.view.animation.AlphaAnimation;
@@ -92,9 +92,7 @@ class CameraMediaChooser extends MediaChooser implements
false /* attachToRoot */); false /* attachToRoot */);
mCameraPreviewHost = (CameraPreview.CameraPreviewHost) view.findViewById( mCameraPreviewHost = (CameraPreview.CameraPreviewHost) view.findViewById(
R.id.camera_preview); R.id.camera_preview);
mCameraPreviewHost.getView().setOnTouchListener(new View.OnTouchListener() { mCameraPreviewHost.getView().setOnTouchListener((view1, motionEvent) -> {
@Override
public boolean onTouch(final View view, final MotionEvent motionEvent) {
if (CameraManager.get().isVideoMode()) { if (CameraManager.get().isVideoMode()) {
// Prevent the swipe down in video mode because video is always captured in // Prevent the swipe down in video mode because video is always captured in
// full screen // full screen
@@ -102,38 +100,25 @@ class CameraMediaChooser extends MediaChooser implements
} }
return false; return false;
}
}); });
final View shutterVisual = view.findViewById(R.id.camera_shutter_visual); final View shutterVisual = view.findViewById(R.id.camera_shutter_visual);
mFullScreenButton = (ImageButton) view.findViewById(R.id.camera_fullScreen_button); mFullScreenButton = (ImageButton) view.findViewById(R.id.camera_fullScreen_button);
mFullScreenButton.setOnClickListener(new View.OnClickListener() { mFullScreenButton.setOnClickListener(view12 -> mMediaPicker.setFullScreen(true));
@Override
public void onClick(final View view) {
mMediaPicker.setFullScreen(true);
}
});
mSwapCameraButton = (ImageButton) view.findViewById(R.id.camera_swapCamera_button); mSwapCameraButton = (ImageButton) view.findViewById(R.id.camera_swapCamera_button);
mSwapCameraButton.setOnClickListener(new View.OnClickListener() { mSwapCameraButton.setOnClickListener(view13 -> CameraManager.get().swapCamera());
@Override
public void onClick(final View view) {
CameraManager.get().swapCamera();
}
});
mCaptureButton = (ImageButton) view.findViewById(R.id.camera_capture_button); mCaptureButton = (ImageButton) view.findViewById(R.id.camera_capture_button);
mCaptureButton.setOnClickListener(new View.OnClickListener() { mCaptureButton.setOnClickListener(v -> {
@Override
public void onClick(final View v) {
final float heightPercent = Math.min(mMediaPicker.getViewPager().getHeight() / final float heightPercent = Math.min(mMediaPicker.getViewPager().getHeight() /
(float) mCameraPreviewHost.getView().getHeight(), 1); (float) mCameraPreviewHost.getView().getHeight(), 1);
if (CameraManager.get().isRecording()) { if (CameraManager.get().isRecording()) {
CameraManager.get().stopVideo(); CameraManager.get().stopVideo();
} else { } else {
final CameraManager.MediaCallback callback = new CameraManager.MediaCallback() { final MediaCallback callback = new MediaCallback() {
@Override @Override
public void onMediaReady( public void onMediaReady(
final Uri uriToVideo, final String contentType, final Uri uriToVideo, final String contentType,
@@ -182,30 +167,23 @@ class CameraMediaChooser extends MediaChooser implements
updateViewState(); updateViewState();
} }
} }
}
}); });
mSwapModeButton = (ImageButton) view.findViewById(R.id.camera_swap_mode_button); mSwapModeButton = (ImageButton) view.findViewById(R.id.camera_swap_mode_button);
mSwapModeButton.setOnClickListener(new View.OnClickListener() { mSwapModeButton.setOnClickListener(view14 -> {
@Override
public void onClick(final View view) {
final boolean isSwitchingToVideo = !CameraManager.get().isVideoMode(); final boolean isSwitchingToVideo = !CameraManager.get().isVideoMode();
if (isSwitchingToVideo && !OsUtil.hasRecordAudioPermission()) { if (isSwitchingToVideo && !OsUtil.hasRecordAudioPermission()) {
requestRecordAudioPermission(); requestRecordAudioPermission();
} else { } else {
onSwapMode(); onSwapMode();
} }
}
}); });
mCancelVideoButton = (ImageButton) view.findViewById(R.id.camera_cancel_button); mCancelVideoButton = (ImageButton) view.findViewById(R.id.camera_cancel_button);
mCancelVideoButton.setOnClickListener(new View.OnClickListener() { mCancelVideoButton.setOnClickListener(view15 -> {
@Override
public void onClick(final View view) {
mVideoCancelled = true; mVideoCancelled = true;
CameraManager.get().stopVideo(); CameraManager.get().stopVideo();
mMediaPicker.dismiss(true); mMediaPicker.dismiss(true);
}
}); });
mVideoCounter = (Chronometer) view.findViewById(R.id.camera_video_counter); mVideoCounter = (Chronometer) view.findViewById(R.id.camera_video_counter);
@@ -83,9 +83,7 @@ public class CameraMediaChooserView extends FrameLayout implements PersistentIns
if (!canvas.isHardwareAccelerated() && !mIsSoftwareFallbackActive) { if (!canvas.isHardwareAccelerated() && !mIsSoftwareFallbackActive) {
mIsSoftwareFallbackActive = true; mIsSoftwareFallbackActive = true;
// Post modifying the tree since we can't modify the view tree during a draw pass // Post modifying the tree since we can't modify the view tree during a draw pass
ThreadUtil.getMainThreadHandler().post(new Runnable() { ThreadUtil.getMainThreadHandler().post(() -> {
@Override
public void run() {
final HardwareCameraPreview cameraPreview = final HardwareCameraPreview cameraPreview =
(HardwareCameraPreview) findViewById(R.id.camera_preview); (HardwareCameraPreview) findViewById(R.id.camera_preview);
if (cameraPreview == null) { if (cameraPreview == null) {
@@ -99,7 +97,6 @@ public class CameraMediaChooserView extends FrameLayout implements PersistentIns
// prevent having 2 camera previews active at the same time // prevent having 2 camera previews active at the same time
parent.removeView(cameraPreview); parent.removeView(cameraPreview);
parent.addView(softwareCameraPreview, index); parent.addView(softwareCameraPreview, index);
}
}); });
} }
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2020 The Android Open Source Project * Copyright (C) 2020 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -77,13 +78,9 @@ class ContactMediaChooser extends MediaChooser {
false /* attachToRoot */); false /* attachToRoot */);
mEnabledView = view.findViewById(R.id.mediapicker_enabled); mEnabledView = view.findViewById(R.id.mediapicker_enabled);
mMissingPermissionView = view.findViewById(R.id.missing_permission_view); mMissingPermissionView = view.findViewById(R.id.missing_permission_view);
mEnabledView.setOnClickListener( mEnabledView.setOnClickListener(v -> {
new View.OnClickListener() {
@Override
public void onClick(final View v) {
// Launch an external picker to pick a contact as attachment. // Launch an external picker to pick a contact as attachment.
UIIntents.get().launchContactCardPicker(mMediaPicker); UIIntents.get().launchContactCardPicker(mMediaPicker);
}
}); });
return view; return view;
} }
@@ -128,14 +125,11 @@ class ContactMediaChooser extends MediaChooser {
} }
final Uri vCardUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey); final Uri vCardUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey);
if (vCardUri != null) { if (vCardUri != null) {
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(() -> {
@Override
public void run() {
final PendingAttachmentData pendingItem = final PendingAttachmentData pendingItem =
PendingAttachmentData.createPendingAttachmentData( PendingAttachmentData.createPendingAttachmentData(
ContentType.TEXT_X_VCARD.toLowerCase(), vCardUri); ContentType.TEXT_X_VCARD.toLowerCase(), vCardUri);
mMediaPicker.dispatchPendingItemAdded(pendingItem); mMediaPicker.dispatchPendingItemAdded(pendingItem);
}
}); });
} }
} }
@@ -92,12 +92,9 @@ public class GalleryGridItemView extends FrameLayout {
mFileName = (TextView) findViewById(R.id.file_name); mFileName = (TextView) findViewById(R.id.file_name);
mFileType = (TextView) findViewById(R.id.file_type); mFileType = (TextView) findViewById(R.id.file_type);
setOnClickListener(mOnClickListener); setOnClickListener(mOnClickListener);
final OnLongClickListener longClickListener = new OnLongClickListener() { final OnLongClickListener longClickListener = v -> {
@Override
public boolean onLongClick(final View v) {
mHostInterface.onItemClicked(v, mData, true /* longClick */); mHostInterface.onItemClicked(v, mData, true /* longClick */);
return true; return true;
}
}; };
setOnLongClickListener(longClickListener); setOnLongClickListener(longClickListener);
mCheckBox.setOnLongClickListener(longClickListener); mCheckBox.setOnLongClickListener(longClickListener);
@@ -38,9 +38,7 @@ import com.android.messaging.datamodel.data.GalleryGridItemData;
import com.android.messaging.datamodel.data.MediaPickerData; import com.android.messaging.datamodel.data.MediaPickerData;
import com.android.messaging.datamodel.data.MessagePartData; import com.android.messaging.datamodel.data.MessagePartData;
import com.android.messaging.datamodel.data.MediaPickerData.MediaPickerDataListener; import com.android.messaging.datamodel.data.MediaPickerData.MediaPickerDataListener;
import com.android.messaging.datamodel.data.PendingAttachmentData;
import com.android.messaging.ui.UIIntents; import com.android.messaging.ui.UIIntents;
import com.android.messaging.ui.mediapicker.DocumentImagePicker.SelectionListener;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
import com.android.messaging.util.OsUtil; import com.android.messaging.util.OsUtil;
@@ -59,14 +57,10 @@ class GalleryMediaChooser extends MediaChooser implements
GalleryMediaChooser(final MediaPicker mediaPicker) { GalleryMediaChooser(final MediaPicker mediaPicker) {
super(mediaPicker); super(mediaPicker);
mAdapter = new GalleryGridAdapter(Factory.get().getApplicationContext(), null); mAdapter = new GalleryGridAdapter(Factory.get().getApplicationContext(), null);
mDocumentImagePicker = new DocumentImagePicker(mMediaPicker, mDocumentImagePicker = new DocumentImagePicker(mMediaPicker, data -> {
new SelectionListener() {
@Override
public void onDocumentSelected(final PendingAttachmentData data) {
if (mBindingRef.isBound()) { if (mBindingRef.isBound()) {
mMediaPicker.dispatchPendingItemAdded(data); mMediaPicker.dispatchPendingItemAdded(data);
} }
}
}); });
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -146,13 +147,9 @@ public class LevelTrackingMediaRecorder {
"media recorder. " + ex); "media recorder. " + ex);
if (mOutputUri != null) { if (mOutputUri != null) {
final Uri outputUri = mOutputUri; final Uri outputUri = mOutputUri;
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(() ->
@Override
public void run() {
Factory.get().getApplicationContext().getContentResolver().delete( Factory.get().getApplicationContext().getContentResolver().delete(
outputUri, null, null); outputUri, null, null));
}
});
mOutputUri = null; mOutputUri = null;
} }
} finally { } finally {
@@ -191,9 +188,7 @@ public class LevelTrackingMediaRecorder {
private void startTrackingSoundLevel() { private void startTrackingSoundLevel() {
stopTrackingSoundLevel(); stopTrackingSoundLevel();
mRefreshLevelThread = new Thread() { mRefreshLevelThread = new Thread(() -> {
@Override
public void run() {
try { try {
while (true) { while (true) {
synchronized (LevelTrackingMediaRecorder.class) { synchronized (LevelTrackingMediaRecorder.class) {
@@ -209,8 +204,7 @@ public class LevelTrackingMediaRecorder {
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} });
};
mRefreshLevelThread.start(); mRefreshLevelThread.start();
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -24,7 +25,6 @@ import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton; import android.widget.ImageButton;
@@ -93,12 +93,7 @@ abstract class MediaChooser extends BasePagerViewHolder
mTabButton.setContentDescription( mTabButton.setContentDescription(
inflater.getContext().getResources().getString(getIconDescriptionResource())); inflater.getContext().getResources().getString(getIconDescriptionResource()));
setSelected(mSelected); setSelected(mSelected);
mTabButton.setOnClickListener(new View.OnClickListener() { mTabButton.setOnClickListener(view -> mMediaPicker.selectChooser(MediaChooser.this));
@Override
public void onClick(final View view) {
mMediaPicker.selectChooser(MediaChooser.this);
}
});
} }
protected Context getContext() { protected Context getContext() {
@@ -543,12 +543,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
mOpen = true; mOpen = true;
mPagerAdapter.notifyDataSetChanged(); mPagerAdapter.notifyDataSetChanged();
if (mListener != null) { if (mListener != null) {
mListenerHandler.post(new Runnable() { mListenerHandler.post(() -> mListener.onOpened());
@Override
public void run() {
mListener.onOpened();
}
});
} }
if (mSelectedChooser != null) { if (mSelectedChooser != null) {
mSelectedChooser.onFullScreenChanged(false); mSelectedChooser.onFullScreenChanged(false);
@@ -560,12 +555,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
setHasOptionsMenu(false); setHasOptionsMenu(false);
mOpen = false; mOpen = false;
if (mListener != null) { if (mListener != null) {
mListenerHandler.post(new Runnable() { mListenerHandler.post(() -> mListener.onDismissed());
@Override
public void run() {
mListener.onDismissed();
}
});
} }
if (mSelectedChooser != null) { if (mSelectedChooser != null) {
mSelectedChooser.onOpenedChanged(false); mSelectedChooser.onOpenedChanged(false);
@@ -575,12 +565,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
void dispatchFullScreen(final boolean fullScreen) { void dispatchFullScreen(final boolean fullScreen) {
setHasOptionsMenu(fullScreen); setHasOptionsMenu(fullScreen);
if (mListener != null) { if (mListener != null) {
mListenerHandler.post(new Runnable() { mListenerHandler.post(() -> mListener.onFullScreenChanged(fullScreen));
@Override
public void run() {
mListener.onFullScreenChanged(fullScreen);
}
});
} }
if (mSelectedChooser != null) { if (mSelectedChooser != null) {
mSelectedChooser.onFullScreenChanged(fullScreen); mSelectedChooser.onFullScreenChanged(fullScreen);
@@ -596,12 +581,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
void dispatchItemsSelected(final Collection<MessagePartData> items, void dispatchItemsSelected(final Collection<MessagePartData> items,
final boolean dismissMediaPicker) { final boolean dismissMediaPicker) {
if (mListener != null) { if (mListener != null) {
mListenerHandler.post(new Runnable() { mListenerHandler.post(() -> mListener.onItemsSelected(items, dismissMediaPicker));
@Override
public void run() {
mListener.onItemsSelected(items, dismissMediaPicker);
}
});
} }
if (isFullScreen() && !dismissMediaPicker) { if (isFullScreen() && !dismissMediaPicker) {
@@ -611,12 +591,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
void dispatchItemUnselected(final MessagePartData item) { void dispatchItemUnselected(final MessagePartData item) {
if (mListener != null) { if (mListener != null) {
mListenerHandler.post(new Runnable() { mListenerHandler.post(() -> mListener.onItemUnselected(item));
@Override
public void run() {
mListener.onItemUnselected(item);
}
});
} }
if (isFullScreen()) { if (isFullScreen()) {
@@ -626,23 +601,13 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
void dispatchConfirmItemSelection() { void dispatchConfirmItemSelection() {
if (mListener != null) { if (mListener != null) {
mListenerHandler.post(new Runnable() { mListenerHandler.post(() -> mListener.onConfirmItemSelection());
@Override
public void run() {
mListener.onConfirmItemSelection();
}
});
} }
} }
void dispatchPendingItemAdded(final PendingAttachmentData pendingItem) { void dispatchPendingItemAdded(final PendingAttachmentData pendingItem) {
if (mListener != null) { if (mListener != null) {
mListenerHandler.post(new Runnable() { mListenerHandler.post(() -> mListener.onPendingItemAdded(pendingItem));
@Override
public void run() {
mListener.onPendingItemAdded(pendingItem);
}
});
} }
if (isFullScreen()) { if (isFullScreen()) {
@@ -652,12 +617,7 @@ public class MediaPicker extends Fragment implements DraftMessageSubscriptionDat
void dispatchChooserSelected(final int chooserIndex) { void dispatchChooserSelected(final int chooserIndex) {
if (mListener != null) { if (mListener != null) {
mListenerHandler.post(new Runnable() { mListenerHandler.post(() -> mListener.onChooserSelected(chooserIndex));
@Override
public void run() {
mListener.onChooserSelected(chooserIndex);
}
});
} }
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -250,12 +251,7 @@ public class MediaPickerPanel extends ViewGroup {
} }
mFullScreen = false; mFullScreen = false;
mExpanded = expanded; mExpanded = expanded;
mHandler.post(new Runnable() { mHandler.post(() -> setDesiredHeight(getDesiredHeight(), animate));
@Override
public void run() {
setDesiredHeight(getDesiredHeight(), animate);
}
});
if (expanded) { if (expanded) {
setupViewPager(startingPage); setupViewPager(startingPage);
mMediaPicker.dispatchOpened(); mMediaPicker.dispatchOpened();
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -110,13 +111,9 @@ class MmsVideoRecorder extends MediaRecorder {
void cleanupTempFile() { void cleanupTempFile() {
final Uri tempUri = mTempVideoUri; final Uri tempUri = mTempVideoUri;
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(() ->
@Override
public void run() {
Factory.get().getApplicationContext().getContentResolver().delete( Factory.get().getApplicationContext().getContentResolver().delete(
tempUri, null, null); tempUri, null, null));
}
});
mTempVideoUri = null; mTempVideoUri = null;
} }
@@ -18,7 +18,6 @@ package com.android.messaging.ui.mediapicker;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.TimeAnimator; import android.animation.TimeAnimator;
import android.animation.TimeAnimator.TimeListener;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
@@ -107,13 +106,7 @@ public class SoundLevels extends View {
// which might improve things further. // which might improve things further.
mSpeechLevelsAnimator = new TimeAnimator(); mSpeechLevelsAnimator = new TimeAnimator();
mSpeechLevelsAnimator.setRepeatCount(ObjectAnimator.INFINITE); mSpeechLevelsAnimator.setRepeatCount(ObjectAnimator.INFINITE);
mSpeechLevelsAnimator.setTimeListener(new TimeListener() { mSpeechLevelsAnimator.setTimeListener((animation, totalTime, deltaTime) -> invalidate());
@Override
public void onTimeUpdate(final TimeAnimator animation, final long totalTime,
final long deltaTime) {
invalidate();
}
});
} }
@Override @Override
+1 -6
View File
@@ -57,12 +57,7 @@ public final class Assert {
// This is called from FactoryImpl once the Gservices class is initialized. // This is called from FactoryImpl once the Gservices class is initialized.
public static void initializeGservices (final BugleGservices gservices) { public static void initializeGservices (final BugleGservices gservices) {
gservices.registerForChanges(new Runnable() { gservices.registerForChanges(() -> refreshGservices(gservices));
@Override
public void run() {
refreshGservices(gservices);
}
});
refreshGservices(gservices); refreshGservices(gservices);
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,7 +21,6 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.os.UserManager; import android.os.UserManager;
import android.text.TextUtils; import android.text.TextUtils;
@@ -68,13 +68,7 @@ public class BugleActivityUtil {
.setMessage(R.string.requires_sms_permissions_message) .setMessage(R.string.requires_sms_permissions_message)
.setCancelable(false) .setCancelable(false)
.setNegativeButton(R.string.requires_sms_permissions_close_button, .setNegativeButton(R.string.requires_sms_permissions_close_button,
new DialogInterface.OnClickListener() { (dialog, button) -> System.exit(0))
@Override
public void onClick(final DialogInterface dialog,
final int button) {
System.exit(0);
}
})
.show(); .show();
return false; return false;
} }
+3 -16
View File
@@ -22,7 +22,6 @@ import android.app.AlertDialog;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.net.Uri; import android.net.Uri;
@@ -50,7 +49,6 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.io.StreamCorruptedException; import java.io.StreamCorruptedException;
@@ -193,13 +191,7 @@ public class DebugUtils {
} }
}); });
builder.setAdapter(arrayAdapter, builder.setAdapter(arrayAdapter, (arg0, pos) -> arrayAdapter.getItem(pos).run());
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface arg0, final int pos) {
arrayAdapter.getItem(pos).run();
}
});
builder.create().show(); builder.create().show();
} }
@@ -231,16 +223,11 @@ public class DebugUtils {
@Override @Override
protected String[] doInBackgroundTimed(final Void... params) { protected String[] doInBackgroundTimed(final Void... params) {
final File dir = DebugUtils.getDebugFilesDir(); final File dir = DebugUtils.getDebugFilesDir();
return dir.list(new FilenameFilter() { return dir.list((dir1, filename) -> filename != null
@Override
public boolean accept(final File dir, final String filename) {
return filename != null
&& ((mAction == DebugSmsMmsFromDumpFileDialogFragment.ACTION_EMAIL && ((mAction == DebugSmsMmsFromDumpFileDialogFragment.ACTION_EMAIL
&& filename.equals(DumpDatabaseAction.DUMP_NAME)) && filename.equals(DumpDatabaseAction.DUMP_NAME))
|| filename.startsWith(MmsUtils.MMS_DUMP_PREFIX) || filename.startsWith(MmsUtils.MMS_DUMP_PREFIX)
|| filename.startsWith(MmsUtils.SMS_DUMP_PREFIX)); || filename.startsWith(MmsUtils.SMS_DUMP_PREFIX)));
}
});
} }
} }
+2 -6
View File
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -58,12 +59,7 @@ public class LogUtil {
// This is called from FactoryImpl once the Gservices class is initialized. // This is called from FactoryImpl once the Gservices class is initialized.
public static void initializeGservices (final BugleGservices gservices) { public static void initializeGservices (final BugleGservices gservices) {
gservices.registerForChanges(new Runnable() { gservices.registerForChanges(() -> refreshGservices(gservices));
@Override
public void run() {
refreshGservices(gservices);
}
});
refreshGservices(gservices); refreshGservices(gservices);
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -42,15 +43,12 @@ public class MediaUtilImpl extends MediaUtil {
afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
afd.close(); afd.close();
mediaPlayer.prepare(); mediaPlayer.prepare();
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { mediaPlayer.setOnCompletionListener(mp -> {
@Override
public void onCompletion(final MediaPlayer mp) {
if (completionListener != null) { if (completionListener != null) {
completionListener.onCompletion(); completionListener.onCompletion();
} }
mp.stop(); mp.stop();
mp.release(); mp.release();
}
}); });
mediaPlayer.seekTo(0); mediaPlayer.seekTo(0);
mediaPlayer.start(); mediaPlayer.start();
@@ -96,16 +96,13 @@ public abstract class SafeAsyncTask<Params, Progress, Result>
Assert.isTrue(mThreadPoolRequested); Assert.isTrue(mThreadPoolRequested);
if (mCancelExecutionOnTimeout) { if (mCancelExecutionOnTimeout) {
ThreadUtil.getMainThreadHandler().postDelayed(new Runnable() { ThreadUtil.getMainThreadHandler().postDelayed(() -> {
@Override
public void run() {
if (getStatus() == Status.RUNNING) { if (getStatus() == Status.RUNNING) {
// Cancel the task if it's still running. // Cancel the task if it's still running.
LogUtil.w(LogUtil.BUGLE_TAG, String.format("%s timed out and is canceled", LogUtil.w(LogUtil.BUGLE_TAG, String.format("%s timed out and is canceled",
this)); this));
cancel(true /* mayInterruptIfRunning */); cancel(true /* mayInterruptIfRunning */);
} }
}
}, mMaxExecutionTimeMillis); }, mMaxExecutionTimeMillis);
} }
@@ -160,15 +157,12 @@ public abstract class SafeAsyncTask<Params, Progress, Result>
if (withWakeLock) { if (withWakeLock) {
final Intent intent = new Intent(); final Intent intent = new Intent();
sWakeLock.acquire(Factory.get().getApplicationContext(), intent, WAKELOCK_OP); sWakeLock.acquire(Factory.get().getApplicationContext(), intent, WAKELOCK_OP);
THREAD_POOL_EXECUTOR.execute(new Runnable() { THREAD_POOL_EXECUTOR.execute(() -> {
@Override
public void run() {
try { try {
runnable.run(); runnable.run();
} finally { } finally {
sWakeLock.release(intent, WAKELOCK_OP); sWakeLock.release(intent, WAKELOCK_OP);
} }
}
}); });
} else { } else {
THREAD_POOL_EXECUTOR.execute(runnable); THREAD_POOL_EXECUTOR.execute(runnable);
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -42,12 +43,7 @@ public class BugleWidgetProvider extends BaseWidgetProvider {
@Override @Override
protected void updateWidget(final Context context, final int appWidgetId) { protected void updateWidget(final Context context, final int appWidgetId) {
if (OsUtil.hasRequiredPermissions()) { if (OsUtil.hasRequiredPermissions()) {
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(() -> rebuildWidget(context, appWidgetId));
@Override
public void run() {
rebuildWidget(context, appWidgetId);
}
});
} else { } else {
AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId,
UiUtils.getWidgetMissingPermissionView(context)); UiUtils.getWidgetMissingPermissionView(context));
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -148,12 +149,7 @@ public class WidgetConversationProvider extends BaseWidgetProvider {
// widget dependent on ConversationListItemData. However, we have to update // widget dependent on ConversationListItemData. However, we have to update
// the widget regardless, even with those missing pieces. Here we update the // the widget regardless, even with those missing pieces. Here we update the
// widget again in the background. // widget again in the background.
SafeAsyncTask.executeOnThreadPool(new Runnable() { SafeAsyncTask.executeOnThreadPool(() -> rebuildWidget(context, appWidgetId));
@Override
public void run() {
rebuildWidget(context, appWidgetId);
}
});
} }
} }