Dialer: Lambs...erm...Lambdas!
Change-Id: I19532d0d6b8f0e821d1908f473b51157f72520e0
diff --git a/java/com/android/contacts/common/dialog/CallSubjectDialog.java b/java/com/android/contacts/common/dialog/CallSubjectDialog.java
index 70d6ba2..1e1ee0d 100644
--- a/java/com/android/contacts/common/dialog/CallSubjectDialog.java
+++ b/java/com/android/contacts/common/dialog/CallSubjectDialog.java
@@ -115,27 +115,19 @@
private SharedPreferences mPrefs;
private List<String> mSubjectHistory;
/** Handles displaying the list of past call subjects. */
- private final View.OnClickListener mHistoryOnClickListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- hideSoftKeyboard(CallSubjectDialog.this, mCallSubjectView);
- showCallHistory(mSubjectList.getVisibility() == View.GONE);
- }
- };
+ private final View.OnClickListener mHistoryOnClickListener = v -> {
+ hideSoftKeyboard(CallSubjectDialog.this, mCallSubjectView);
+ showCallHistory(mSubjectList.getVisibility() == View.GONE);
+ };
/**
* Handles auto-hiding the call history when user clicks in the call subject field to give it
* focus.
*/
- private final View.OnClickListener mCallSubjectClickListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mSubjectList.getVisibility() == View.VISIBLE) {
- showCallHistory(false);
- }
- }
- };
+ private final View.OnClickListener mCallSubjectClickListener = v -> {
+ if (mSubjectList.getVisibility() == View.VISIBLE) {
+ showCallHistory(false);
+ }
+ };
private long mPhotoID;
private Uri mPhotoUri;
@@ -147,43 +139,31 @@
private int mContactType;
private PhoneAccountHandle mPhoneAccountHandle;
/** Handles starting a call with a call subject specified. */
- private final View.OnClickListener mSendAndCallOnClickListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String subject = mCallSubjectView.getText().toString();
- PreCall.start(
- CallSubjectDialog.this,
- new CallIntentBuilder(mNumber, CallInitiationType.Type.CALL_SUBJECT_DIALOG)
- .setPhoneAccountHandle(mPhoneAccountHandle)
- .setCallSubject(subject));
+ private final View.OnClickListener mSendAndCallOnClickListener = v -> {
+ String subject = mCallSubjectView.getText().toString();
+ PreCall.start(
+ CallSubjectDialog.this,
+ new CallIntentBuilder(mNumber, CallInitiationType.Type.CALL_SUBJECT_DIALOG)
+ .setPhoneAccountHandle(mPhoneAccountHandle)
+ .setCallSubject(subject));
- mSubjectHistory.add(subject);
- saveSubjectHistory(mSubjectHistory);
- finish();
- }
- };
+ mSubjectHistory.add(subject);
+ saveSubjectHistory(mSubjectHistory);
+ finish();
+ };
+
/** Click listener which handles user clicks outside of the dialog. */
- private View.OnClickListener mBackgroundListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- };
+ private final View.OnClickListener mBackgroundListener = v -> finish();
/**
* Item click listener which handles user clicks on the items in the list view. Dismisses the
* activity, returning the subject to the caller and closing the activity with the {@link
* Activity#RESULT_OK} result code.
*/
- private AdapterView.OnItemClickListener mItemClickListener =
- new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
- mCallSubjectView.setText(mSubjectHistory.get(position));
- showCallHistory(false);
- }
- };
+ private final AdapterView.OnItemClickListener mItemClickListener =
+ (arg0, view, position, arg3) -> {
+ mCallSubjectView.setText(mSubjectHistory.get(position));
+ showCallHistory(false);
+ };
/**
* Show the call subject dialog given a phone number to dial (e.g. from the dialpad).
diff --git a/java/com/android/contacts/common/list/ViewPagerTabs.java b/java/com/android/contacts/common/list/ViewPagerTabs.java
index acbe1e5..5ab23b8 100644
--- a/java/com/android/contacts/common/list/ViewPagerTabs.java
+++ b/java/com/android/contacts/common/list/ViewPagerTabs.java
@@ -184,13 +184,7 @@
tabView = textView;
}
- tabView.setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- mPager.setCurrentItem(getRtlPosition(position));
- }
- });
+ tabView.setOnClickListener(v -> mPager.setCurrentItem(getRtlPosition(position)));
tabView.setOnLongClickListener(new OnTabLongClickListener(position));
diff --git a/java/com/android/contacts/common/model/AccountTypeManager.java b/java/com/android/contacts/common/model/AccountTypeManager.java
index f5b113c..070c9a7 100644
--- a/java/com/android/contacts/common/model/AccountTypeManager.java
+++ b/java/com/android/contacts/common/model/AccountTypeManager.java
@@ -174,37 +174,33 @@
private static final int MESSAGE_LOAD_DATA = 0;
private static final int MESSAGE_PROCESS_BROADCAST_INTENT = 1;
- private static final Comparator<AccountWithDataSet> ACCOUNT_COMPARATOR =
- new Comparator<AccountWithDataSet>() {
- @Override
- public int compare(AccountWithDataSet a, AccountWithDataSet b) {
- if (Objects.equals(a.name, b.name)
- && Objects.equals(a.type, b.type)
- && Objects.equals(a.dataSet, b.dataSet)) {
- return 0;
- } else if (b.name == null || b.type == null) {
- return -1;
- } else if (a.name == null || a.type == null) {
- return 1;
- } else {
- int diff = a.name.compareTo(b.name);
- if (diff != 0) {
- return diff;
- }
- diff = a.type.compareTo(b.type);
- if (diff != 0) {
- return diff;
- }
+ private static final Comparator<AccountWithDataSet> ACCOUNT_COMPARATOR = (a, b) -> {
+ if (Objects.equals(a.name, b.name)
+ && Objects.equals(a.type, b.type)
+ && Objects.equals(a.dataSet, b.dataSet)) {
+ return 0;
+ } else if (b.name == null || b.type == null) {
+ return -1;
+ } else if (a.name == null || a.type == null) {
+ return 1;
+ } else {
+ int diff = a.name.compareTo(b.name);
+ if (diff != 0) {
+ return diff;
+ }
+ diff = a.type.compareTo(b.type);
+ if (diff != 0) {
+ return diff;
+ }
- // Accounts without data sets get sorted before those that have them.
- if (a.dataSet != null) {
- return b.dataSet == null ? 1 : a.dataSet.compareTo(b.dataSet);
- } else {
- return -1;
- }
- }
- }
- };
+ // Accounts without data sets get sorted before those that have them.
+ if (a.dataSet != null) {
+ return b.dataSet == null ? 1 : a.dataSet.compareTo(b.dataSet);
+ } else {
+ return -1;
+ }
+ }
+ };
private final InvitableAccountTypeCache mInvitableAccountTypeCache;
/**
* The boolean value is equal to true if the {@link InvitableAccountTypeCache} has been
diff --git a/java/com/android/contacts/common/model/account/BaseAccountType.java b/java/com/android/contacts/common/model/account/BaseAccountType.java
index 1cf4151..d96e28c 100644
--- a/java/com/android/contacts/common/model/account/BaseAccountType.java
+++ b/java/com/android/contacts/common/model/account/BaseAccountType.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,28 +53,22 @@
public abstract class BaseAccountType extends AccountType {
- public static final StringInflater ORGANIZATION_BODY_INFLATER =
- new StringInflater() {
- @Override
- public CharSequence inflateUsing(Context context, ContentValues values) {
- final CharSequence companyValue =
- values.containsKey(Organization.COMPANY)
- ? values.getAsString(Organization.COMPANY)
- : null;
- final CharSequence titleValue =
- values.containsKey(Organization.TITLE)
- ? values.getAsString(Organization.TITLE)
- : null;
+ public static final StringInflater ORGANIZATION_BODY_INFLATER = (context, values) -> {
+ final CharSequence companyValue = values.containsKey(Organization.COMPANY)
+ ? values.getAsString(Organization.COMPANY)
+ : null;
+ final CharSequence titleValue = values.containsKey(Organization.TITLE)
+ ? values.getAsString(Organization.TITLE)
+ : null;
- if (companyValue != null && titleValue != null) {
- return companyValue + ": " + titleValue;
- } else if (companyValue == null) {
- return titleValue;
- } else {
- return companyValue;
- }
- }
- };
+ if (companyValue != null && titleValue != null) {
+ return companyValue + ": " + titleValue;
+ } else if (companyValue == null) {
+ return titleValue;
+ } else {
+ return companyValue;
+ }
+ };
protected static final int FLAGS_PHONE = EditorInfo.TYPE_CLASS_PHONE;
protected static final int FLAGS_EMAIL =
EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
diff --git a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
index b4d7b82..0b3575b 100644
--- a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
+++ b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
@@ -102,31 +102,23 @@
isSelected = false;
final DialogInterface.OnClickListener selectionListener =
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- isSelected = true;
- PhoneAccountHandle selectedAccountHandle =
- SelectPhoneAccountDialogOptionsUtil.getPhoneAccountHandle(
- options.getEntriesList().get(which));
- Bundle result = new Bundle();
- result.putParcelable(
- SelectPhoneAccountListener.EXTRA_SELECTED_ACCOUNT_HANDLE, selectedAccountHandle);
- result.putBoolean(SelectPhoneAccountListener.EXTRA_SET_DEFAULT, isDefaultChecked);
- result.putString(SelectPhoneAccountListener.EXTRA_CALL_ID, getCallId());
- if (listener != null) {
- listener.onReceiveResult(SelectPhoneAccountListener.RESULT_SELECTED, result);
- }
- }
- };
+ (dialog, which) -> {
+ isSelected = true;
+ PhoneAccountHandle selectedAccountHandle =
+ SelectPhoneAccountDialogOptionsUtil.getPhoneAccountHandle(
+ options.getEntriesList().get(which));
+ Bundle result = new Bundle();
+ result.putParcelable(
+ SelectPhoneAccountListener.EXTRA_SELECTED_ACCOUNT_HANDLE, selectedAccountHandle);
+ result.putBoolean(SelectPhoneAccountListener.EXTRA_SET_DEFAULT, isDefaultChecked);
+ result.putString(SelectPhoneAccountListener.EXTRA_CALL_ID, getCallId());
+ if (listener != null) {
+ listener.onReceiveResult(SelectPhoneAccountListener.RESULT_SELECTED, result);
+ }
+ };
final CompoundButton.OnCheckedChangeListener checkListener =
- new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton check, boolean isChecked) {
- isDefaultChecked = isChecked;
- }
- };
+ (check, isChecked) -> isDefaultChecked = isChecked;
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
ListAdapter selectAccountListAdapter =
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java
index d4f16b2..6057649 100644
--- a/java/com/android/dialer/app/calllog/CallLogAdapter.java
+++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java
@@ -205,34 +205,17 @@
.getResources()
.getQuantityString(
R.plurals.delete_voicemails_confirmation_dialog_title, selectedItems.size()))
- .setPositiveButton(
- R.string.voicemailMultiSelectDeleteConfirm,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(final DialogInterface dialog, final int button) {
- LogUtil.i(
- "CallLogAdapter.showDeleteSelectedItemsDialog",
- "onClick, these items to delete " + voicemailsToDeleteOnConfirmation);
- deleteSelectedItems(voicemailsToDeleteOnConfirmation);
- actionMode.finish();
- dialog.cancel();
- }
- })
- .setOnCancelListener(
- new OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialogInterface) {
- dialogInterface.cancel();
- }
- })
- .setNegativeButton(
- R.string.voicemailMultiSelectDeleteCancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(final DialogInterface dialog, final int button) {
- dialog.cancel();
- }
- })
+ .setPositiveButton(R.string.voicemailMultiSelectDeleteConfirm, (dialog, button) -> {
+ LogUtil.i(
+ "CallLogAdapter.showDeleteSelectedItemsDialog",
+ "onClick, these items to delete " + voicemailsToDeleteOnConfirmation);
+ deleteSelectedItems(voicemailsToDeleteOnConfirmation);
+ actionMode.finish();
+ dialog.cancel();
+ })
+ .setOnCancelListener(dialogInterface -> dialogInterface.cancel())
+ .setNegativeButton(R.string.voicemailMultiSelectDeleteCancel,
+ (dialog, button) -> dialog.cancel())
.show();
}
diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java
index d88306b..3442d73 100644
--- a/java/com/android/dialer/app/calllog/CallLogFragment.java
+++ b/java/com/android/dialer/app/calllog/CallLogFragment.java
@@ -256,16 +256,12 @@
}
// Workaround for framework issue: the smooth-scroll doesn't
// occur if setSelection() is called immediately before.
- handler.post(
- new Runnable() {
- @Override
- public void run() {
- if (getActivity() == null || getActivity().isFinishing()) {
- return;
- }
- recyclerView.smoothScrollToPosition(0);
- }
- });
+ handler.post(() -> {
+ if (getActivity() == null || getActivity().isFinishing()) {
+ return;
+ }
+ recyclerView.smoothScrollToPosition(0);
+ });
scrollToTop = false;
}
diff --git a/java/com/android/dialer/app/calllog/VoicemailNotificationJobService.java b/java/com/android/dialer/app/calllog/VoicemailNotificationJobService.java
index 754ab27..c6ea069 100644
--- a/java/com/android/dialer/app/calllog/VoicemailNotificationJobService.java
+++ b/java/com/android/dialer/app/calllog/VoicemailNotificationJobService.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,11 +53,7 @@
@Override
public boolean onStartJob(JobParameters params) {
LogUtil.i("VoicemailNotificationJobService.onStartJob", "updating notification");
- VisualVoicemailUpdateTask.scheduleTask(
- this,
- () -> {
- jobFinished(params, false);
- });
+ VisualVoicemailUpdateTask.scheduleTask(this, () -> jobFinished(params, false));
return true; // Running in background
}
diff --git a/java/com/android/dialer/app/calllog/VoicemailQueryHandler.java b/java/com/android/dialer/app/calllog/VoicemailQueryHandler.java
index cad838a..c2729bc 100644
--- a/java/com/android/dialer/app/calllog/VoicemailQueryHandler.java
+++ b/java/com/android/dialer/app/calllog/VoicemailQueryHandler.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,10 +47,8 @@
@WorkerThread
public static void markAllNewVoicemailsAsOld(final @NonNull Context context) {
ThreadUtil.postOnUiThread(
- () -> {
- new VoicemailQueryHandler(context.getContentResolver())
- .markNewVoicemailsAsOld(context, null);
- });
+ () -> new VoicemailQueryHandler(context.getContentResolver())
+ .markNewVoicemailsAsOld(context, null));
}
@WorkerThread
@@ -60,10 +59,8 @@
return;
}
ThreadUtil.postOnUiThread(
- () -> {
- new VoicemailQueryHandler(context.getContentResolver())
- .markNewVoicemailsAsOld(context, voicemailUri);
- });
+ () -> new VoicemailQueryHandler(context.getContentResolver())
+ .markNewVoicemailsAsOld(context, voicemailUri));
}
/** Updates all new voicemails to mark them as old. */
diff --git a/java/com/android/dialer/app/settings/SoundSettingsFragment.java b/java/com/android/dialer/app/settings/SoundSettingsFragment.java
index 128ebdc..b274339 100644
--- a/java/com/android/dialer/app/settings/SoundSettingsFragment.java
+++ b/java/com/android/dialer/app/settings/SoundSettingsFragment.java
@@ -20,7 +20,6 @@
import android.app.AlertDialog;
import android.app.NotificationManager;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.media.RingtoneManager;
import android.os.Bundle;
@@ -67,13 +66,8 @@
}
}
};
- private final Runnable ringtoneLookupRunnable =
- new Runnable() {
- @Override
- public void run() {
- updateRingtonePreferenceSummary();
- }
- };
+ private final Runnable ringtoneLookupRunnable = () -> updateRingtonePreferenceSummary();
+
private SwitchPreferenceCompat vibrateWhenRinging;
private SwitchPreferenceCompat playDtmfTone;
private ListPreference dtmfToneLength;
@@ -201,20 +195,12 @@
if (newValue && !notificationManager.isNotificationPolicyAccessGranted()) {
new AlertDialog.Builder(getContext())
.setMessage(R.string.incall_dnd_dialog_message)
- .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
- startActivity(intent);
- }
+ .setPositiveButton(R.string.allow, (dialog, which) -> {
+ dialog.dismiss();
+ Intent intent = new Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
+ startActivity(intent);
})
- .setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
+ .setNegativeButton(R.string.deny, (dialog, which) -> dialog.dismiss())
.show();
// At this time, it is unknown whether the user granted the permission
diff --git a/java/com/android/dialer/app/voicemail/VoicemailPlaybackLayout.java b/java/com/android/dialer/app/voicemail/VoicemailPlaybackLayout.java
index 99967dc..3f80220 100644
--- a/java/com/android/dialer/app/voicemail/VoicemailPlaybackLayout.java
+++ b/java/com/android/dialer/app/voicemail/VoicemailPlaybackLayout.java
@@ -92,16 +92,12 @@
presenter.onVoicemailDeleted(viewHolder);
final Uri deleteUri = voicemailUri;
- final Runnable deleteCallback =
- new Runnable() {
- @Override
- public void run() {
- if (Objects.equals(deleteUri, voicemailUri)) {
- CallLogAsyncTaskUtil.deleteVoicemail(
- context, deleteUri, VoicemailPlaybackLayout.this);
- }
- }
- };
+ final Runnable deleteCallback = () -> {
+ if (Objects.equals(deleteUri, voicemailUri)) {
+ CallLogAsyncTaskUtil.deleteVoicemail(
+ context, deleteUri, VoicemailPlaybackLayout.this);
+ }
+ };
final Handler handler = new Handler();
// Add a little buffer time in case the user clicked "undo" at the end of the delay
@@ -113,15 +109,10 @@
R.string.snackbar_voicemail_deleted,
Snackbar.LENGTH_LONG)
.setDuration(VOICEMAIL_DELETE_DELAY_MS)
- .setAction(
- R.string.snackbar_undo,
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- presenter.onVoicemailDeleteUndo(adapterPosition);
- handler.removeCallbacks(deleteCallback);
- }
- })
+ .setAction(R.string.snackbar_undo, view1 -> {
+ presenter.onVoicemailDeleteUndo(adapterPosition);
+ handler.removeCallbacks(deleteCallback);
+ })
.setActionTextColor(
context.getResources().getColor(R.color.dialer_snackbar_action_text_color))
.show();
diff --git a/java/com/android/dialer/binary/aosp/AospDialerApplication.java b/java/com/android/dialer/binary/aosp/AospDialerApplication.java
index fd50110..52366ce 100644
--- a/java/com/android/dialer/binary/aosp/AospDialerApplication.java
+++ b/java/com/android/dialer/binary/aosp/AospDialerApplication.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -81,12 +82,6 @@
@Override
public PhoneNumberCacheBindings newPhoneNumberCacheBindings() {
- return new PhoneNumberCacheBindings() {
- @Override
- @Nullable
- public CachedNumberLookupService getCachedNumberLookupService() {
- return new LookupCacheService();
- }
- };
+ return LookupCacheService::new;
}
}
diff --git a/java/com/android/dialer/callstats/CallStatsAdapter.java b/java/com/android/dialer/callstats/CallStatsAdapter.java
index b55190e..2f18a8c 100644
--- a/java/com/android/dialer/callstats/CallStatsAdapter.java
+++ b/java/com/android/dialer/callstats/CallStatsAdapter.java
@@ -135,8 +135,7 @@
mTotalItem = new CallStatsDetails(null, 0, null, null, null, null, null, 0);
mInfoLookup = new ConcurrentHashMap<>();
- mContactInfoCache = new ContactInfoCache(cache,
- mContactInfoHelper, () -> notifyDataSetChanged());
+ mContactInfoCache = new ContactInfoCache(cache, mContactInfoHelper, this::notifyDataSetChanged);
if (!PermissionsUtil.hasContactsReadPermissions(context)) {
mContactInfoCache.disableRequestProcessing();
}
diff --git a/java/com/android/dialer/callstats/DoubleDatePickerDialog.java b/java/com/android/dialer/callstats/DoubleDatePickerDialog.java
index ffbf46a..e0c40bf 100644
--- a/java/com/android/dialer/callstats/DoubleDatePickerDialog.java
+++ b/java/com/android/dialer/callstats/DoubleDatePickerDialog.java
@@ -106,51 +106,20 @@
};
private static final QuickSelection[] QUICKSELECTIONS = new QuickSelection[] {
- new QuickSelection() {
- @Override
- public void adjustStartDate(Calendar date) {
- date.set(Calendar.DAY_OF_MONTH, 1);
- }
- },
- new QuickSelection() {
- @Override
- public void adjustStartDate(Calendar date) {
- final int currentMonth = date.get(Calendar.MONTH);
- date.set(Calendar.MONTH, currentMonth - (currentMonth % 3));
- date.set(Calendar.DAY_OF_MONTH, 1);
- }
- },
- new QuickSelection() {
- @Override
- public void adjustStartDate(Calendar date) {
- date.set(Calendar.MONTH, 0);
- date.set(Calendar.DAY_OF_MONTH, 1);
- }
- },
- new QuickSelection() {
- @Override
- public void adjustStartDate(Calendar date) {
- date.add(Calendar.WEEK_OF_YEAR, -1);
- }
- },
- new QuickSelection() {
- @Override
- public void adjustStartDate(Calendar date) {
- date.add(Calendar.MONTH, -1);
- }
- },
- new QuickSelection() {
- @Override
- public void adjustStartDate(Calendar date) {
- date.add(Calendar.MONTH, -3);
- }
- },
- new QuickSelection() {
- @Override
- public void adjustStartDate(Calendar date) {
- date.add(Calendar.YEAR, -1);
- }
- },
+ date -> date.set(Calendar.DAY_OF_MONTH, 1),
+ date -> {
+ final int currentMonth = date.get(Calendar.MONTH);
+ date.set(Calendar.MONTH, currentMonth - (currentMonth % 3));
+ date.set(Calendar.DAY_OF_MONTH, 1);
+ },
+ date -> {
+ date.set(Calendar.MONTH, 0);
+ date.set(Calendar.DAY_OF_MONTH, 1);
+ },
+ date -> date.add(Calendar.WEEK_OF_YEAR, -1),
+ date -> date.add(Calendar.MONTH, -1),
+ date -> date.add(Calendar.MONTH, -3),
+ date -> date.add(Calendar.YEAR, -1),
};
private static final String YEAR = "year";
diff --git a/java/com/android/dialer/common/concurrent/DialerExecutorModule.java b/java/com/android/dialer/common/concurrent/DialerExecutorModule.java
index 98738ed..b8659b1 100644
--- a/java/com/android/dialer/common/concurrent/DialerExecutorModule.java
+++ b/java/com/android/dialer/common/concurrent/DialerExecutorModule.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,16 +57,13 @@
static ExecutorService provideNonUiThreadPool() {
return Executors.newFixedThreadPool(
5,
- new ThreadFactory() {
- @Override
- public Thread newThread(Runnable runnable) {
- LogUtil.i("DialerExecutorModule.newThread", "creating low priority thread");
- Thread thread = new Thread(runnable, "DialerExecutors-LowPriority");
- // Java thread priority 4 corresponds to Process.THREAD_PRIORITY_BACKGROUND (10)
- thread.setPriority(4);
- return thread;
- }
- });
+ runnable -> {
+ LogUtil.i("DialerExecutorModule.newThread", "creating low priority thread");
+ Thread thread = new Thread(runnable, "DialerExecutors-LowPriority");
+ // Java thread priority 4 corresponds to Process.THREAD_PRIORITY_BACKGROUND (10)
+ thread.setPriority(4);
+ return thread;
+ });
}
@Provides
@@ -73,16 +71,13 @@
@NonUiSerial
static ScheduledExecutorService provideNonUiSerialExecutorService() {
return Executors.newSingleThreadScheduledExecutor(
- new ThreadFactory() {
- @Override
- public Thread newThread(Runnable runnable) {
- LogUtil.i("NonUiTaskBuilder.newThread", "creating serial thread");
- Thread thread = new Thread(runnable, "DialerExecutors-LowPriority-Serial");
- // Java thread priority 4 corresponds to Process.THREAD_PRIORITY_BACKGROUND (10)
- thread.setPriority(4);
- return thread;
- }
- });
+ runnable -> {
+ LogUtil.i("NonUiTaskBuilder.newThread", "creating serial thread");
+ Thread thread = new Thread(runnable, "DialerExecutors-LowPriority-Serial");
+ // Java thread priority 4 corresponds to Process.THREAD_PRIORITY_BACKGROUND (10)
+ thread.setPriority(4);
+ return thread;
+ });
}
@Provides
@@ -96,16 +91,13 @@
@UiSerial
static ScheduledExecutorService provideUiSerialExecutorService() {
return Executors.newSingleThreadScheduledExecutor(
- new ThreadFactory() {
- @Override
- public Thread newThread(Runnable runnable) {
- LogUtil.i("DialerExecutorModule.newThread", "creating serial thread");
- Thread thread = new Thread(runnable, "DialerExecutors-HighPriority-Serial");
- // Java thread priority 5 corresponds to Process.THREAD_PRIORITY_DEFAULT (0)
- thread.setPriority(5);
- return thread;
- }
- });
+ runnable -> {
+ LogUtil.i("DialerExecutorModule.newThread", "creating serial thread");
+ Thread thread = new Thread(runnable, "DialerExecutors-HighPriority-Serial");
+ // Java thread priority 5 corresponds to Process.THREAD_PRIORITY_DEFAULT (0)
+ thread.setPriority(5);
+ return thread;
+ });
}
@Provides
diff --git a/java/com/android/dialer/common/concurrent/DialerFutures.java b/java/com/android/dialer/common/concurrent/DialerFutures.java
index ac88e6a..0c9f455 100644
--- a/java/com/android/dialer/common/concurrent/DialerFutures.java
+++ b/java/com/android/dialer/common/concurrent/DialerFutures.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,34 +58,31 @@
final AtomicInteger pending = new AtomicInteger(output.futures.size());
for (final ListenableFuture<? extends T> future : output.futures) {
future.addListener(
- new Runnable() {
- @Override
- public void run() {
- // Call get() and then set() instead of getAndSet() because a volatile read/write is
- // cheaper than a CAS and atomicity is guaranteed by setFuture.
- AggregateFuture<T> output = ref.get();
- if (output != null) {
- T value = null;
- try {
- value = Futures.getDone(future);
- } catch (ExecutionException e) {
- ref.set(null); // unpin
- output.setException(e);
- return;
- }
- if (!predicate.apply(value)) {
- if (pending.decrementAndGet() == 0) {
- // we are the last future (and every other future hasn't matched or failed).
- output.set(defaultValue);
- // no point in clearing the ref, every other listener has already run
+ () -> {
+ // Call get() and then set() instead of getAndSet() because a volatile read/write is
+ // cheaper than a CAS and atomicity is guaranteed by setFuture.
+ AggregateFuture<T> output1 = ref.get();
+ if (output1 != null) {
+ T value = null;
+ try {
+ value = Futures.getDone(future);
+ } catch (ExecutionException e) {
+ ref.set(null); // unpin
+ output1.setException(e);
+ return;
}
- } else {
- ref.set(null); // unpin
- output.set(value);
+ if (!predicate.apply(value)) {
+ if (pending.decrementAndGet() == 0) {
+ // we are the last future (and every other future hasn't matched or failed).
+ output1.set(defaultValue);
+ // no point in clearing the ref, every other listener has already run
+ }
+ } else {
+ ref.set(null); // unpin
+ output1.set(value);
+ }
}
- }
- }
- },
+ },
MoreExecutors.directExecutor());
}
return output;
diff --git a/java/com/android/dialer/helplines/HelplineActivity.java b/java/com/android/dialer/helplines/HelplineActivity.java
index fefe692..5a62489 100755
--- a/java/com/android/dialer/helplines/HelplineActivity.java
+++ b/java/com/android/dialer/helplines/HelplineActivity.java
@@ -141,8 +141,7 @@
.setTitle(R.string.helplines_help_title)
.setMessage(R.string.helplines_help_message)
.setPositiveButton(android.R.string.ok, null)
- .setNeutralButton(R.string.helpline_button_more, (dialog, which) -> {
- showMoreInfo(); })
+ .setNeutralButton(R.string.helpline_button_more, (dialog, which) -> showMoreInfo())
.show();
}
diff --git a/java/com/android/dialer/helplines/HelplineAdapter.java b/java/com/android/dialer/helplines/HelplineAdapter.java
index 26e9011..1f67686 100644
--- a/java/com/android/dialer/helplines/HelplineAdapter.java
+++ b/java/com/android/dialer/helplines/HelplineAdapter.java
@@ -125,9 +125,7 @@
}
void bind(HelplineItem item) {
- mItemView.setOnClickListener(v -> {
- mListener.onItemClicked(item);
- });
+ mItemView.setOnClickListener(v -> mListener.onItemClicked(item));
String name = item.getName();
if (!TextUtils.isEmpty(name)) {
@@ -151,9 +149,7 @@
String number = item.getItem().getNumber();
if (!TextUtils.isEmpty(number)) {
mCallIcon.setVisibility(View.VISIBLE);
- mCallIcon.setOnClickListener(v -> {
- mListener.initiateCall(number);
- });
+ mCallIcon.setOnClickListener(v -> mListener.initiateCall(number));
}
}
}
diff --git a/java/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java b/java/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java
index 68b011a..76f7ade 100644
--- a/java/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java
+++ b/java/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,15 +51,12 @@
if (TextUtils.isEmpty(number)) {
return;
}
- new Thread() {
- @Override
- public void run() {
- final long id = getContactIdFromPhoneNumber(context, number);
- if (id != NO_CONTACT_FOUND) {
- undemoteContactWithId(context, id);
- }
+ new Thread(() -> {
+ final long id = getContactIdFromPhoneNumber(context, number);
+ if (id != NO_CONTACT_FOUND) {
+ undemoteContactWithId(context, id);
}
- }.start();
+ }).start();
}
}
diff --git a/java/com/android/dialer/lookup/LookupProvider.java b/java/com/android/dialer/lookup/LookupProvider.java
index 42d7dd2..3061b55 100644
--- a/java/com/android/dialer/lookup/LookupProvider.java
+++ b/java/com/android/dialer/lookup/LookupProvider.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Xiao-Long Chen <chillermillerlong@hotmail.com>
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -166,12 +167,9 @@
final Location finalLastLocation = lastLocation;
final int finalMaxResults = maxResults;
- return execute(new Callable<Cursor>() {
- @Override
- public Cursor call() {
- return handleFilter(match, projection, filter, finalMaxResults, finalLastLocation);
- }
- }, "FilterThread");
+ return execute(
+ () -> handleFilter(match, projection, filter, finalMaxResults, finalLastLocation),
+ "FilterThread");
}
return null;
diff --git a/java/com/android/dialer/notification/NotificationThrottler.java b/java/com/android/dialer/notification/NotificationThrottler.java
index f55f815..c34a883 100644
--- a/java/com/android/dialer/notification/NotificationThrottler.java
+++ b/java/com/android/dialer/notification/NotificationThrottler.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -112,14 +113,7 @@
notifications.add(notification);
}
}
- Collections.sort(
- notifications,
- new Comparator<StatusBarNotification>() {
- @Override
- public int compare(StatusBarNotification left, StatusBarNotification right) {
- return Long.compare(left.getPostTime(), right.getPostTime());
- }
- });
+ notifications.sort(Comparator.comparingLong(StatusBarNotification::getPostTime));
return notifications;
}
diff --git a/java/com/android/dialer/simulator/impl/SimulatorVideoCall.java b/java/com/android/dialer/simulator/impl/SimulatorVideoCall.java
index 3c7cb3b..9dfe078 100644
--- a/java/com/android/dialer/simulator/impl/SimulatorVideoCall.java
+++ b/java/com/android/dialer/simulator/impl/SimulatorVideoCall.java
@@ -79,7 +79,7 @@
handleNewConnection(connection);
// Telecom will force the connection to switch to Dialing when we return it. Wait until after
// we're returned it before changing call state.
- ThreadUtil.postOnUiThread(() -> connection.setActive());
+ ThreadUtil.postOnUiThread(connection::setActive);
}
}
diff --git a/java/com/android/dialer/simulator/service/SimulatorService.java b/java/com/android/dialer/simulator/service/SimulatorService.java
index 974a3ee..1b679b5 100644
--- a/java/com/android/dialer/simulator/service/SimulatorService.java
+++ b/java/com/android/dialer/simulator/service/SimulatorService.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -89,34 +90,22 @@
@Override
public void populateDataBase() throws RemoteException {
- doSecurityCheck(
- () -> {
- simulatorMainPortal.execute(new String[] {POPULATE_DATABASE});
- });
+ doSecurityCheck(() -> simulatorMainPortal.execute(new String[] {POPULATE_DATABASE}));
}
@Override
public void cleanDataBase() throws RemoteException {
- doSecurityCheck(
- () -> {
- simulatorMainPortal.execute(new String[] {CLEAN_DATABASE});
- });
+ doSecurityCheck(() -> simulatorMainPortal.execute(new String[] {CLEAN_DATABASE}));
}
@Override
public void enableSimulatorMode() throws RemoteException {
- doSecurityCheck(
- () -> {
- simulatorMainPortal.execute(new String[] {ENABLE_SIMULATOR_MODE});
- });
+ doSecurityCheck(() -> simulatorMainPortal.execute(new String[] {ENABLE_SIMULATOR_MODE}));
}
@Override
public void disableSimulatorMode() throws RemoteException {
- doSecurityCheck(
- () -> {
- simulatorMainPortal.execute(new String[] {DISABLE_SIMULATOR_MODE});
- });
+ doSecurityCheck(() -> simulatorMainPortal.execute(new String[] {DISABLE_SIMULATOR_MODE}));
}
@Override
diff --git a/java/com/android/dialer/util/DialerUtils.java b/java/com/android/dialer/util/DialerUtils.java
index 13c4929..ff0ba4f 100644
--- a/java/com/android/dialer/util/DialerUtils.java
+++ b/java/com/android/dialer/util/DialerUtils.java
@@ -95,13 +95,7 @@
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(R.string.outgoing_wps_warning);
builder.setPositiveButton(
- R.string.dialog_continue,
- new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- placeCallOrMakeToast(context, intent);
- }
- });
+ R.string.dialog_continue, (dialog, which) -> placeCallOrMakeToast(context, intent));
builder.setNegativeButton(android.R.string.cancel, null);
builder.create().show();
} else {
diff --git a/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessage.java b/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessage.java
index cb1c329..c73a563 100644
--- a/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessage.java
+++ b/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +23,6 @@
import android.provider.VoicemailContract;
import android.telecom.PhoneAccountHandle;
import android.view.View;
-import android.view.View.OnClickListener;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -130,13 +130,10 @@
public static Action createChangeAirplaneModeAction(final Context context) {
return new Action(
context.getString(R.string.voicemail_action_turn_off_airplane_mode),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS);
- context.startActivity(intent);
- }
- });
+ v -> {
+ Intent intent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS);
+ context.startActivity(intent);
+ });
}
@NonNull
@@ -144,14 +141,11 @@
final Context context, PhoneAccountHandle phoneAccountHandle) {
return new Action(
context.getString(R.string.voicemail_action_set_pin),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(context, VoicemailChangePinActivity.class);
- intent.putExtra(VoicemailClient.PARAM_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
- context.startActivity(intent);
- }
- });
+ v -> {
+ Intent intent = new Intent(context, VoicemailChangePinActivity.class);
+ intent.putExtra(VoicemailClient.PARAM_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
+ context.startActivity(intent);
+ });
}
@NonNull
@@ -159,43 +153,32 @@
final Context context) {
return new Action(
context.getString(R.string.voicemail_action_call_voicemail),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- PreCall.start(
+ v -> PreCall.start(
context,
CallIntentBuilder.forVoicemail(
- CallInitiationType.Type.VOICEMAIL_ERROR_MESSAGE));
- }
- });
+ CallInitiationType.Type.VOICEMAIL_ERROR_MESSAGE)));
}
@NonNull
public static Action createSyncAction(final Context context, final VoicemailStatus status) {
return new Action(
context.getString(R.string.voicemail_action_sync),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL);
- intent.setPackage(status.sourcePackage);
- context.sendBroadcast(intent);
- }
- });
+ v -> {
+ Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL);
+ intent.setPackage(status.sourcePackage);
+ context.sendBroadcast(intent);
+ });
}
@NonNull
public static Action createRetryAction(final Context context, final VoicemailStatus status) {
return new Action(
context.getString(R.string.voicemail_action_retry),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL);
- intent.setPackage(status.sourcePackage);
- context.sendBroadcast(intent);
- }
- });
+ v -> {
+ Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL);
+ intent.setPackage(status.sourcePackage);
+ context.sendBroadcast(intent);
+ });
}
@NonNull
@@ -207,20 +190,17 @@
PhoneAccountHandle phoneAccountHandle) {
return new Action(
context.getString(R.string.voicemail_action_turn_archive_on),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- Assert.checkArgument(
- VoicemailComponent.get(context)
- .getVoicemailClient()
- .isVoicemailArchiveAvailable(context));
- voicemailClient.setVoicemailArchiveEnabled(context, phoneAccountHandle, true);
- Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL);
- intent.setPackage(status.sourcePackage);
- context.sendBroadcast(intent);
- statusReader.refresh();
- }
- });
+ v -> {
+ Assert.checkArgument(
+ VoicemailComponent.get(context)
+ .getVoicemailClient()
+ .isVoicemailArchiveAvailable(context));
+ voicemailClient.setVoicemailArchiveEnabled(context, phoneAccountHandle, true);
+ Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL);
+ intent.setPackage(status.sourcePackage);
+ context.sendBroadcast(intent);
+ statusReader.refresh();
+ });
}
@NonNull
@@ -231,16 +211,13 @@
String preferenceKeyToUpdate) {
return new Action(
context.getString(R.string.voicemail_action_dimiss),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- Assert.checkArgument(
- VoicemailComponent.get(context)
- .getVoicemailClient()
- .isVoicemailArchiveAvailable(context));
- sharedPreferenceForAccount.edit().putBoolean(preferenceKeyToUpdate, true).apply();
- statusReader.refresh();
- }
- });
+ v -> {
+ Assert.checkArgument(
+ VoicemailComponent.get(context)
+ .getVoicemailClient()
+ .isVoicemailArchiveAvailable(context));
+ sharedPreferenceForAccount.edit().putBoolean(preferenceKeyToUpdate, true).apply();
+ statusReader.refresh();
+ });
}
}
diff --git a/java/com/android/dialer/voicemail/listui/error/VoicemailTosMessageCreator.java b/java/com/android/dialer/voicemail/listui/error/VoicemailTosMessageCreator.java
index 63cee71..1ce09dd 100644
--- a/java/com/android/dialer/voicemail/listui/error/VoicemailTosMessageCreator.java
+++ b/java/com/android/dialer/voicemail/listui/error/VoicemailTosMessageCreator.java
@@ -89,29 +89,23 @@
getNewUserTosMessageText(),
new Action(
getDeclineText(),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- LogUtil.i("VoicemailTosMessageCreator.getTosMessage", "decline clicked");
- PhoneAccountHandle handle =
- new PhoneAccountHandle(
- ComponentName.unflattenFromString(status.phoneAccountComponentName),
- status.phoneAccountId);
- showDeclineTosDialog(handle);
- }
- }),
+ v -> {
+ LogUtil.i("VoicemailTosMessageCreator.getTosMessage", "decline clicked");
+ PhoneAccountHandle handle =
+ new PhoneAccountHandle(
+ ComponentName.unflattenFromString(status.phoneAccountComponentName),
+ status.phoneAccountId);
+ showDeclineTosDialog(handle);
+ }),
new Action(
getAcceptText(),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- LogUtil.i("VoicemailTosMessageCreator.getTosMessage", "accept clicked");
- recordTosAcceptance();
- // Accepting the TOS also acknowledges the latest features
- recordFeatureAcknowledgement();
- statusReader.refresh();
- }
- },
+ v -> {
+ LogUtil.i("VoicemailTosMessageCreator.getTosMessage", "accept clicked");
+ recordTosAcceptance();
+ // Accepting the TOS also acknowledges the latest features
+ recordFeatureAcknowledgement();
+ statusReader.refresh();
+ },
true /* raised */))
.setModal(true)
.setImageResourceId(R.drawable.voicemail_tos_image);
@@ -174,28 +168,15 @@
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.terms_and_conditions_decline_dialog_title);
builder.setMessage(getTosDeclinedDialogMessageId());
- builder.setPositiveButton(
- getTosDeclinedDialogDowngradeId(),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- VoicemailClient voicemailClient = VoicemailComponent.get(context).getVoicemailClient();
- if (voicemailClient.isVoicemailModuleEnabled()) {
- voicemailClient.setVoicemailEnabled(context, status.getPhoneAccountHandle(), false);
- } else {
- TelephonyManagerCompat.setVisualVoicemailEnabled(telephonyManager, handle, false);
- }
- }
- });
-
- builder.setNegativeButton(
- android.R.string.cancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- });
+ builder.setPositiveButton(getTosDeclinedDialogDowngradeId(), (dialog, which) -> {
+ VoicemailClient voicemailClient = VoicemailComponent.get(context).getVoicemailClient();
+ if (voicemailClient.isVoicemailModuleEnabled()) {
+ voicemailClient.setVoicemailEnabled(context, status.getPhoneAccountHandle(), false);
+ } else {
+ TelephonyManagerCompat.setVisualVoicemailEnabled(telephonyManager, handle, false);
+ }
+ });
+ builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss());
builder.setCancelable(true);
builder.show();
@@ -206,23 +187,12 @@
builder.setMessage(R.string.verizon_terms_and_conditions_decline_set_pin_dialog_message);
builder.setPositiveButton(
R.string.verizon_terms_and_conditions_decline_set_pin_dialog_set_pin,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Intent intent = new Intent(TelephonyManager.ACTION_CONFIGURE_VOICEMAIL);
- intent.putExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
- context.startActivity(intent);
- }
- });
-
- builder.setNegativeButton(
- android.R.string.cancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- });
+ (dialog, which) -> {
+ Intent intent = new Intent(TelephonyManager.ACTION_CONFIGURE_VOICEMAIL);
+ intent.putExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
+ context.startActivity(intent);
+ });
+ builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss());
builder.setCancelable(true);
builder.show();
diff --git a/java/com/android/dialer/voicemail/listui/error/Vvm3VoicemailMessageCreator.java b/java/com/android/dialer/voicemail/listui/error/Vvm3VoicemailMessageCreator.java
index 84bbe60..9da10e9 100644
--- a/java/com/android/dialer/voicemail/listui/error/Vvm3VoicemailMessageCreator.java
+++ b/java/com/android/dialer/voicemail/listui/error/Vvm3VoicemailMessageCreator.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -288,18 +289,15 @@
private static Action createCallCustomerSupportAction(final Context context) {
return new Action(
context.getString(R.string.voicemail_action_call_customer_support),
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent =
- new Intent(
- Intent.ACTION_CALL,
- Uri.parse(
- "tel:"
- + context.getString(
- R.string.verizon_domestic_customer_support_number)));
- context.startActivity(intent);
- }
- });
+ v -> {
+ Intent intent =
+ new Intent(
+ Intent.ACTION_CALL,
+ Uri.parse(
+ "tel:"
+ + context.getString(
+ R.string.verizon_domestic_customer_support_number)));
+ context.startActivity(intent);
+ });
}
}
diff --git a/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java b/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
index 47d8ee3..45c5cc0 100644
--- a/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
+++ b/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
@@ -166,12 +166,7 @@
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
activity.showError(
activity.getString(R.string.change_pin_system_error),
- new OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
- activity.finish();
- }
- });
+ dialog -> activity.finish());
} else {
LogUtil.e(TAG, "invalid default old PIN: " + activity.getChangePinResultMessage(result));
// If the default old PIN is rejected by the server, the PIN is probably changed
diff --git a/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java b/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java
index 49d4a60..942f396 100644
--- a/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java
+++ b/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java
@@ -18,7 +18,6 @@
package com.android.dialer.voicemail.settings;
import android.app.AlertDialog;
-import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
@@ -303,26 +302,16 @@
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.confirm_disable_voicemail_dialog_title);
builder.setMessage(R.string.confirm_disable_voicemail_dialog_message);
- builder.setPositiveButton(
- R.string.confirm_disable_voicemail_accept_dialog_label,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- LogUtil.i(TAG, "showDisableConfirmationDialog, confirmed");
- updateVoicemailEnabled(false);
- dialog.dismiss();
- }
- });
-
- builder.setNegativeButton(
- android.R.string.cancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- LogUtil.i(TAG, "showDisableConfirmationDialog, cancelled");
- dialog.dismiss();
- }
- });
+ builder.setPositiveButton(R.string.confirm_disable_voicemail_accept_dialog_label,
+ (dialog, which) -> {
+ LogUtil.i(TAG, "showDisableConfirmationDialog, confirmed");
+ updateVoicemailEnabled(false);
+ dialog.dismiss();
+ });
+ builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> {
+ LogUtil.i(TAG, "showDisableConfirmationDialog, cancelled");
+ dialog.dismiss();
+ });
builder.setCancelable(true);
builder.show();
diff --git a/java/com/android/incallui/CallerInfoUtils.java b/java/com/android/incallui/CallerInfoUtils.java
index 6f73f2f..27cb6a8 100644
--- a/java/com/android/incallui/CallerInfoUtils.java
+++ b/java/com/android/incallui/CallerInfoUtils.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,12 +20,10 @@
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import android.content.Context;
-import android.content.Loader;
-import android.content.Loader.OnLoadCompleteListener;
import android.net.Uri;
import android.telecom.TelecomManager;
import android.text.TextUtils;
-import com.android.contacts.common.model.Contact;
+
import com.android.contacts.common.model.ContactLoader;
import com.android.dialer.common.LogUtil;
import com.android.dialer.phonenumbercache.CachedNumberLookupService;
@@ -268,15 +267,11 @@
final ContactLoader loader =
new ContactLoader(context, contactUri, true /* postViewNotification */);
loader.registerListener(
- 0,
- new OnLoadCompleteListener<Contact>() {
- @Override
- public void onLoadComplete(Loader<Contact> loader, Contact contact) {
- try {
- loader.reset();
- } catch (RuntimeException e) {
- LogUtil.e("CallerInfoUtils.onLoadComplete", "Error resetting loader", e);
- }
+ 0, (loader1, contact) -> {
+ try {
+ loader1.reset();
+ } catch (RuntimeException e) {
+ LogUtil.e("CallerInfoUtils.onLoadComplete", "Error resetting loader", e);
}
});
loader.startLoading();
diff --git a/java/com/android/incallui/ConferenceParticipantListAdapter.java b/java/com/android/incallui/ConferenceParticipantListAdapter.java
index 3760342..38e8e86 100644
--- a/java/com/android/incallui/ConferenceParticipantListAdapter.java
+++ b/java/com/android/incallui/ConferenceParticipantListAdapter.java
@@ -65,30 +65,21 @@
/** Contact photo manager to retrieve cached contact photo information. */
private final ContactPhotoManager contactPhotoManager;
/** Listener used to handle tap of the "disconnect' button for a participant. */
- private View.OnClickListener disconnectListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- DialerCall call = getCallFromView(view);
- LogUtil.i(
- "ConferenceParticipantListAdapter.mDisconnectListener.onClick", "call: " + call);
- if (call != null) {
- call.disconnect();
- }
- }
- };
+ private final View.OnClickListener disconnectListener = view -> {
+ DialerCall call = getCallFromView(view);
+ LogUtil.i("ConferenceParticipantListAdapter.mDisconnectListener.onClick", "call: " + call);
+ if (call != null) {
+ call.disconnect();
+ }
+ };
/** Listener used to handle tap of the "separate' button for a participant. */
- private View.OnClickListener separateListener =
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- DialerCall call = getCallFromView(view);
- LogUtil.i("ConferenceParticipantListAdapter.mSeparateListener.onClick", "call: " + call);
- if (call != null) {
- call.splitFromConference();
- }
- }
- };
+ private final View.OnClickListener separateListener = view -> {
+ DialerCall call = getCallFromView(view);
+ LogUtil.i("ConferenceParticipantListAdapter.mSeparateListener.onClick", "call: " + call);
+ if (call != null) {
+ call.splitFromConference();
+ }
+ };
/** The conference participants to show in the ListView. */
private final List<ParticipantInfo> conferenceParticipants = new ArrayList<>();
/** {@code True} if the conference parent supports separating calls from the conference. */
@@ -430,29 +421,24 @@
/** Sorts the participant list by contact name. */
private void sortParticipantList() {
- Collections.sort(
- conferenceParticipants,
- new Comparator<ParticipantInfo>() {
- @Override
- public int compare(ParticipantInfo p1, ParticipantInfo p2) {
- // Contact names might be null, so replace with empty string.
- ContactCacheEntry c1 = p1.getContactCacheEntry();
- String p1Name =
- ContactsComponent.get(getContext())
- .contactDisplayPreferences()
- .getSortName(c1.namePrimary, c1.nameAlternative);
- p1Name = p1Name != null ? p1Name : "";
+ conferenceParticipants.sort((p1, p2) -> {
+ // Contact names might be null, so replace with empty string.
+ ContactCacheEntry c1 = p1.getContactCacheEntry();
+ String p1Name =
+ ContactsComponent.get(getContext())
+ .contactDisplayPreferences()
+ .getSortName(c1.namePrimary, c1.nameAlternative);
+ p1Name = p1Name != null ? p1Name : "";
- ContactCacheEntry c2 = p2.getContactCacheEntry();
- String p2Name =
- ContactsComponent.get(getContext())
- .contactDisplayPreferences()
- .getSortName(c2.namePrimary, c2.nameAlternative);
- p2Name = p2Name != null ? p2Name : "";
+ ContactCacheEntry c2 = p2.getContactCacheEntry();
+ String p2Name =
+ ContactsComponent.get(getContext())
+ .contactDisplayPreferences()
+ .getSortName(c2.namePrimary, c2.nameAlternative);
+ p2Name = p2Name != null ? p2Name : "";
- return p1Name.compareToIgnoreCase(p2Name);
- }
- });
+ return p1Name.compareToIgnoreCase(p2Name);
+ });
}
private DialerCall getCallFromView(View view) {
diff --git a/java/com/android/incallui/PostCharDialogFragment.java b/java/com/android/incallui/PostCharDialogFragment.java
index 228482d..42e3d34 100644
--- a/java/com/android/incallui/PostCharDialogFragment.java
+++ b/java/com/android/incallui/PostCharDialogFragment.java
@@ -64,20 +64,8 @@
builder.setPositiveButton(
R.string.pause_prompt_yes,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int whichButton) {
- TelecomAdapter.getInstance().postDialContinue(callId, true);
- }
- });
- builder.setNegativeButton(
- R.string.pause_prompt_no,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int whichButton) {
- dialog.cancel();
- }
- });
+ (dialog, whichButton) -> TelecomAdapter.getInstance().postDialContinue(callId, true));
+ builder.setNegativeButton(R.string.pause_prompt_no, (dialog, whichButton) -> dialog.cancel());
final AlertDialog dialog = builder.create();
return dialog;
diff --git a/java/com/android/incallui/VideoCallPresenter.java b/java/com/android/incallui/VideoCallPresenter.java
index b054724..3f92453 100644
--- a/java/com/android/incallui/VideoCallPresenter.java
+++ b/java/com/android/incallui/VideoCallPresenter.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -129,24 +130,20 @@
* enter fullscreen mode if the dialpad is visible (doing so would make it impossible to exit the
* dialpad).
*/
- private Runnable autoFullscreenRunnable =
- new Runnable() {
- @Override
- public void run() {
- if (autoFullScreenPending
- && !InCallPresenter.getInstance().isDialpadVisible()
- && isVideoMode) {
+ private final Runnable autoFullscreenRunnable = () -> {
+ if (autoFullScreenPending
+ && !InCallPresenter.getInstance().isDialpadVisible()
+ && isVideoMode) {
- LogUtil.v("VideoCallPresenter.mAutoFullScreenRunnable", "entering fullscreen mode");
- InCallPresenter.getInstance().setFullScreen(true);
- autoFullScreenPending = false;
- } else {
- LogUtil.v(
- "VideoCallPresenter.mAutoFullScreenRunnable",
- "skipping scheduled fullscreen mode.");
- }
- }
- };
+ LogUtil.v("VideoCallPresenter.mAutoFullScreenRunnable", "entering fullscreen mode");
+ InCallPresenter.getInstance().setFullScreen(true);
+ autoFullScreenPending = false;
+ } else {
+ LogUtil.v(
+ "VideoCallPresenter.mAutoFullScreenRunnable",
+ "skipping scheduled fullscreen mode.");
+ }
+ };
private boolean isVideoCallScreenUiReady;
diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java
index a171b22..5f13ba7 100644
--- a/java/com/android/incallui/answer/impl/AnswerFragment.java
+++ b/java/com/android/incallui/answer/impl/AnswerFragment.java
@@ -230,14 +230,10 @@
answerAndReleaseButton
.animate()
.alpha(0)
- .withEndAction(
- new Runnable() {
- @Override
- public void run() {
- affordanceHolderLayout.reset(false);
- secondaryButton.animate().alpha(1);
- }
- });
+ .withEndAction(() -> {
+ affordanceHolderLayout.reset(false);
+ secondaryButton.animate().alpha(1);
+ });
}
private final AccessibilityDelegate accessibilityDelegate =
@@ -410,13 +406,7 @@
: SecondaryBehavior.REJECT_WITH_SMS;
secondaryBehavior.applyToView(secondaryButton);
- secondaryButton.setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- performSecondaryButtonAction();
- }
- });
+ secondaryButton.setOnClickListener(v -> performSecondaryButtonAction());
secondaryButton.setClickable(AccessibilityUtil.isAccessibilityEnabled(getContext()));
secondaryButton.setFocusable(AccessibilityUtil.isAccessibilityEnabled(getContext()));
secondaryButton.setAccessibilityDelegate(accessibilityDelegate);
@@ -441,13 +431,7 @@
answerAndReleaseButton.setVisibility(View.INVISIBLE);
answerScreenDelegate.onAnswerAndReleaseButtonDisabled();
}
- answerAndReleaseButton.setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- performAnswerAndReleaseButtonAction();
- }
- });
+ answerAndReleaseButton.setOnClickListener(v -> performAnswerAndReleaseButtonAction());
}
/** Initialize chip buttons */
@@ -684,18 +668,14 @@
importanceBadge = view.findViewById(R.id.incall_important_call_badge);
importanceBadge
.getViewTreeObserver()
- .addOnGlobalLayoutListener(
- new OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- int leftRightPadding = importanceBadge.getHeight() / 2;
- importanceBadge.setPadding(
- leftRightPadding,
- importanceBadge.getPaddingTop(),
- leftRightPadding,
- importanceBadge.getPaddingBottom());
- }
- });
+ .addOnGlobalLayoutListener(() -> {
+ int leftRightPadding = importanceBadge.getHeight() / 2;
+ importanceBadge.setPadding(
+ leftRightPadding,
+ importanceBadge.getPaddingTop(),
+ leftRightPadding,
+ importanceBadge.getPaddingBottom());
+ });
updateImportanceBadgeVisibility();
contactGridManager = new ContactGridManager(view, null, 0, false /* showAnonymousAvatar */);
@@ -988,14 +968,10 @@
secondaryButton
.animate()
.alpha(0)
- .withEndAction(
- new Runnable() {
- @Override
- public void run() {
- affordanceHolderLayout.reset(false);
- secondaryButton.animate().alpha(1);
- }
- });
+ .withEndAction(() -> {
+ affordanceHolderLayout.reset(false);
+ secondaryButton.animate().alpha(1);
+ });
TelecomUtil.silenceRinger(getContext());
}
diff --git a/java/com/android/incallui/answer/impl/CreateCustomSmsDialogFragment.java b/java/com/android/incallui/answer/impl/CreateCustomSmsDialogFragment.java
index b6a192b..d14d59f 100644
--- a/java/com/android/incallui/answer/impl/CreateCustomSmsDialogFragment.java
+++ b/java/com/android/incallui/answer/impl/CreateCustomSmsDialogFragment.java
@@ -20,7 +20,6 @@
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
-import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnShowListener;
import android.os.Bundle;
import android.text.Editable;
@@ -69,43 +68,21 @@
builder
.setCancelable(true)
.setView(view)
- .setPositiveButton(
- R.string.call_incoming_custom_message_send,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- FragmentUtils.getParentUnsafe(
- CreateCustomSmsDialogFragment.this, CreateCustomSmsHolder.class)
+ .setPositiveButton(R.string.call_incoming_custom_message_send, (dialogInterface, i) -> {
+ FragmentUtils.getParentUnsafe(
+ CreateCustomSmsDialogFragment.this, CreateCustomSmsHolder.class)
.customSmsCreated(editText.getText().toString().trim());
- dismiss();
- }
- })
- .setNegativeButton(
- R.string.call_incoming_custom_message_cancel,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- dismiss();
- }
- })
- .setOnCancelListener(
- new OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialogInterface) {
- dismiss();
- }
- })
+ dismiss();
+ })
+ .setNegativeButton(R.string.call_incoming_custom_message_cancel,
+ (dialogInterface, i) -> dismiss())
+ .setOnCancelListener(dialogInterface -> dismiss())
.setTitle(R.string.call_incoming_respond_via_sms_custom_message);
final AlertDialog customMessagePopup = builder.create();
customMessagePopup.setOnShowListener(
- new OnShowListener() {
- @Override
- public void onShow(DialogInterface dialogInterface) {
- ((AlertDialog) dialogInterface)
- .getButton(AlertDialog.BUTTON_POSITIVE)
- .setEnabled(false);
- }
- });
+ dialogInterface -> ((AlertDialog) dialogInterface)
+ .getButton(AlertDialog.BUTTON_POSITIVE)
+ .setEnabled(false));
editText.addTextChangedListener(
new TextWatcher() {
diff --git a/java/com/android/incallui/answer/impl/SmsBottomSheetFragment.java b/java/com/android/incallui/answer/impl/SmsBottomSheetFragment.java
index d3f0ca1..d8b5ba4 100644
--- a/java/com/android/incallui/answer/impl/SmsBottomSheetFragment.java
+++ b/java/com/android/incallui/answer/impl/SmsBottomSheetFragment.java
@@ -26,7 +26,6 @@
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
@@ -116,14 +115,11 @@
textView.setLayoutParams(params);
textView.setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- FragmentUtils.getParentUnsafe(SmsBottomSheetFragment.this, SmsSheetHolder.class)
- .smsSelected(text);
- dismiss();
- }
- });
+ v -> {
+ FragmentUtils.getParentUnsafe(SmsBottomSheetFragment.this, SmsSheetHolder.class)
+ .smsSelected(text);
+ dismiss();
+ });
return textView;
}
diff --git a/java/com/android/incallui/answer/impl/affordance/SwipeButtonHelper.java b/java/com/android/incallui/answer/impl/affordance/SwipeButtonHelper.java
index 3271162..5895f9c 100644
--- a/java/com/android/incallui/answer/impl/affordance/SwipeButtonHelper.java
+++ b/java/com/android/incallui/answer/impl/affordance/SwipeButtonHelper.java
@@ -340,16 +340,13 @@
}
ValueAnimator animator = ValueAnimator.ofFloat(targetView.getCircleRadius(), radius);
animator.addUpdateListener(
- new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- float newRadius = (float) animation.getAnimatedValue();
- targetView.setCircleRadiusWithoutAnimation(newRadius);
- float translation = getTranslationFromRadius(newRadius);
- SwipeButtonHelper.this.translation = right ? -translation : translation;
- updateIconsFromTranslation(targetView);
- }
- });
+ animation -> {
+ float newRadius = (float) animation.getAnimatedValue();
+ targetView.setCircleRadiusWithoutAnimation(newRadius);
+ float translation = getTranslationFromRadius(newRadius);
+ SwipeButtonHelper.this.translation = right ? -translation : translation;
+ updateIconsFromTranslation(targetView);
+ });
return animator;
}
@@ -388,13 +385,7 @@
ValueAnimator animator = ValueAnimator.ofFloat(translation, target);
flingAnimationUtils.apply(animator, translation, target, vel);
- animator.addUpdateListener(
- new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- translation = (float) animation.getAnimatedValue();
- }
- });
+ animator.addUpdateListener(animation -> translation = (float) animation.getAnimatedValue());
animator.addListener(flingEndListener);
if (!snapBack) {
startFinishingCircleAnimation(vel * 0.375f, new AnimationEndRunnable(right), right);
diff --git a/java/com/android/incallui/answer/impl/affordance/SwipeButtonView.java b/java/com/android/incallui/answer/impl/affordance/SwipeButtonView.java
index a875723..133e714 100644
--- a/java/com/android/incallui/answer/impl/affordance/SwipeButtonView.java
+++ b/java/com/android/incallui/answer/impl/affordance/SwipeButtonView.java
@@ -336,15 +336,11 @@
circleAnimator = animator;
circleStartValue = this.circleRadius;
circleWillBeHidden = circleRadius == 0.0f;
- animator.addUpdateListener(
- new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- SwipeButtonView.this.circleRadius = (float) animation.getAnimatedValue();
- updateIconColor();
- invalidate();
- }
- });
+ animator.addUpdateListener(animation -> {
+ SwipeButtonView.this.circleRadius = (float) animation.getAnimatedValue();
+ updateIconColor();
+ invalidate();
+ });
animator.addListener(circleEndListener);
return animator;
}
@@ -377,14 +373,10 @@
} else {
ValueAnimator animator = ValueAnimator.ofFloat(tmageScale, imageScale);
scaleAnimator = animator;
- animator.addUpdateListener(
- new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- tmageScale = (float) animation.getAnimatedValue();
- invalidate();
- }
- });
+ animator.addUpdateListener(animation -> {
+ tmageScale = (float) animation.getAnimatedValue();
+ invalidate();
+ });
animator.addListener(scaleEndListener);
if (interpolator == null) {
interpolator =
@@ -446,17 +438,13 @@
int currentAlpha = getImageAlpha();
ValueAnimator animator = ValueAnimator.ofInt(currentAlpha, endAlpha);
alphaAnimator = animator;
- animator.addUpdateListener(
- new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- int alpha = (int) animation.getAnimatedValue();
- if (background != null) {
- background.mutate().setAlpha(alpha);
- }
- setImageAlpha(alpha);
- }
- });
+ animator.addUpdateListener(animation -> {
+ int alpha1 = (int) animation.getAnimatedValue();
+ if (background != null) {
+ background.mutate().setAlpha(alpha1);
+ }
+ setImageAlpha(alpha1);
+ });
animator.addListener(alphaEndListener);
if (interpolator == null) {
interpolator =
diff --git a/java/com/android/incallui/answer/impl/answermethod/FlingUpDownTouchHandler.java b/java/com/android/incallui/answer/impl/answermethod/FlingUpDownTouchHandler.java
index f42e6bd..afaf799 100644
--- a/java/com/android/incallui/answer/impl/answermethod/FlingUpDownTouchHandler.java
+++ b/java/com/android/incallui/answer/impl/answermethod/FlingUpDownTouchHandler.java
@@ -425,13 +425,8 @@
private ValueAnimator createProgressAnimator(float targetProgress) {
ValueAnimator animator = ValueAnimator.ofFloat(currentProgress, targetProgress);
- animator.addUpdateListener(
- new AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- setCurrentProgress((Float) animation.getAnimatedValue());
- }
- });
+ animator.addUpdateListener(animation ->
+ setCurrentProgress((Float) animation.getAnimatedValue()));
return animator;
}
diff --git a/java/com/android/incallui/incall/impl/MappedButtonConfig.java b/java/com/android/incallui/incall/impl/MappedButtonConfig.java
index 0d7e273..f313b00 100644
--- a/java/com/android/incallui/incall/impl/MappedButtonConfig.java
+++ b/java/com/android/incallui/incall/impl/MappedButtonConfig.java
@@ -112,16 +112,13 @@
*/
@NonNull
public Comparator<Integer> getSlotComparator() {
- return new Comparator<Integer>() {
- @Override
- public int compare(Integer lhs, Integer rhs) {
- MappingInfo lhsInfo = lookupMappingInfo(lhs);
- MappingInfo rhsInfo = lookupMappingInfo(rhs);
- if (lhsInfo.getSlot() != rhsInfo.getSlot()) {
- throw new IllegalArgumentException("lhs and rhs don't go in the same slot");
- }
- return lhsInfo.getSlotOrder() - rhsInfo.getSlotOrder();
+ return (lhs, rhs) -> {
+ MappingInfo lhsInfo = lookupMappingInfo(lhs);
+ MappingInfo rhsInfo = lookupMappingInfo(rhs);
+ if (lhsInfo.getSlot() != rhsInfo.getSlot()) {
+ throw new IllegalArgumentException("lhs and rhs don't go in the same slot");
}
+ return lhsInfo.getSlotOrder() - rhsInfo.getSlotOrder();
};
}
@@ -136,13 +133,10 @@
*/
@NonNull
public Comparator<Integer> getConflictComparator() {
- return new Comparator<Integer>() {
- @Override
- public int compare(Integer lhs, Integer rhs) {
- MappingInfo lhsInfo = lookupMappingInfo(lhs);
- MappingInfo rhsInfo = lookupMappingInfo(rhs);
- return lhsInfo.getConflictOrder() - rhsInfo.getConflictOrder();
- }
+ return (lhs, rhs) -> {
+ MappingInfo lhsInfo = lookupMappingInfo(lhs);
+ MappingInfo rhsInfo = lookupMappingInfo(rhs);
+ return lhsInfo.getConflictOrder() - rhsInfo.getConflictOrder();
};
}
diff --git a/java/com/android/incallui/ringtone/InCallTonePlayer.java b/java/com/android/incallui/ringtone/InCallTonePlayer.java
index 7261d1e..3f7d81a 100644
--- a/java/com/android/incallui/ringtone/InCallTonePlayer.java
+++ b/java/com/android/incallui/ringtone/InCallTonePlayer.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +25,7 @@
import com.android.incallui.Log;
import com.android.incallui.async.PausableExecutor;
+
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -76,13 +78,7 @@
}
final ToneGeneratorInfo info = getToneGeneratorInfo(tone);
numPlayingTones = new CountDownLatch(1);
- executor.execute(
- new Runnable() {
- @Override
- public void run() {
- playOnBackgroundThread(info);
- }
- });
+ executor.execute(() -> playOnBackgroundThread(info));
}
private ToneGeneratorInfo getToneGeneratorInfo(int tone) {
diff --git a/java/com/android/incallui/rtt/impl/AudioSelectMenu.java b/java/com/android/incallui/rtt/impl/AudioSelectMenu.java
index 1c83637..b9cd358 100644
--- a/java/com/android/incallui/rtt/impl/AudioSelectMenu.java
+++ b/java/com/android/incallui/rtt/impl/AudioSelectMenu.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,10 +72,7 @@
} else if (audioState.getRoute() == itemRoute) {
item.setChecked(true);
}
- item.setOnClickListener(
- (v) -> {
- inCallButtonUiDelegate.setAudioRoute(itemRoute);
- });
+ item.setOnClickListener(v -> inCallButtonUiDelegate.setAudioRoute(itemRoute));
}
void setAudioState(CallAudioState audioState) {
diff --git a/java/com/android/incallui/spam/SpamCallListListener.java b/java/com/android/incallui/spam/SpamCallListListener.java
index 96eac1b..cc05509 100644
--- a/java/com/android/incallui/spam/SpamCallListListener.java
+++ b/java/com/android/incallui/spam/SpamCallListListener.java
@@ -27,7 +27,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import com.android.dialer.R;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.DialerExecutor.Worker;
@@ -117,7 +116,7 @@
new NumberInCallHistoryWorker(context, number, call.getCountryIso());
dialerExecutorFactory
.createNonUiTaskBuilder(historyTask)
- .onSuccess((result) -> call.setCallHistoryStatus(result))
+ .onSuccess(call::setCallHistoryStatus)
.build()
.executeParallel(null);
}
diff --git a/java/com/android/incallui/spam/SpamNotificationActivity.java b/java/com/android/incallui/spam/SpamNotificationActivity.java
index ca561e2..63b0235 100644
--- a/java/com/android/incallui/spam/SpamNotificationActivity.java
+++ b/java/com/android/incallui/spam/SpamNotificationActivity.java
@@ -297,32 +297,22 @@
.setTitle(getString(R.string.spam_notification_title,
getFormattedNumber(number, applicationContext)))
.setNeutralButton(getString(R.string.spam_notification_action_dismiss),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dismiss();
- }
- })
+ (dialog, which) -> dismiss())
.setPositiveButton(getString(R.string.spam_notification_block_spam_action_text),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dismissed = true;
- dismiss();
- spamNotificationActivity.maybeShowBlockReportSpamDialog(
- number, contactLookupResultType);
- spamNotificationActivity.maybeShowSpamBlockingPromoAndFinish();
- }
- })
+ (dialog, which) -> {
+ dismissed = true;
+ dismiss();
+ spamNotificationActivity.maybeShowBlockReportSpamDialog(
+ number, contactLookupResultType);
+ spamNotificationActivity.maybeShowSpamBlockingPromoAndFinish();
+ })
.setNegativeButton(getString(R.string.spam_notification_was_not_spam_action_text),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dismissed = true;
- dismiss();
- spamNotificationActivity.maybeShowNotSpamDialog(number, contactLookupResultType);
- }
- })
+ (dialog, which) -> {
+ dismissed = true;
+ dismiss();
+ spamNotificationActivity.maybeShowNotSpamDialog(number,
+ contactLookupResultType);
+ })
.create();
}
}
@@ -379,34 +369,23 @@
.setMessage(getString(R.string.spam_notification_non_spam_call_expanded_text))
.setNeutralButton(
getString(R.string.spam_notification_action_dismiss),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dismiss();
- }
- })
+ (dialog, which) -> dismiss())
.setPositiveButton(
getString(R.string.spam_notification_dialog_add_contact_action_text),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dismissed = true;
- dismiss();
- startActivity(createInsertContactsIntent(number));
- }
- })
+ (dialog, which) -> {
+ dismissed = true;
+ dismiss();
+ startActivity(createInsertContactsIntent(number));
+ })
.setNegativeButton(
getString(R.string.spam_notification_dialog_block_report_spam_action_text),
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dismissed = true;
- dismiss();
- spamNotificationActivity.maybeShowBlockReportSpamDialog(
- number, contactLookupResultType);
- spamNotificationActivity.maybeShowSpamBlockingPromoAndFinish();
- }
- })
+ (dialog, which) -> {
+ dismissed = true;
+ dismiss();
+ spamNotificationActivity.maybeShowBlockReportSpamDialog(
+ number, contactLookupResultType);
+ spamNotificationActivity.maybeShowSpamBlockingPromoAndFinish();
+ })
.create();
}
}
diff --git a/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java b/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java
index d554a58..0b12594 100644
--- a/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java
+++ b/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java
@@ -209,13 +209,7 @@
endCallButton.setOnClickListener(this);
previewSurfaceView = (SurfaceView) view.findViewById(R.id.videocall_video_preview);
previewSurfaceView.setZOrderMediaOverlay(true);
- previewOffOverlay.setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- checkCameraPermission();
- }
- });
+ previewOffOverlay.setOnClickListener(v -> checkCameraPermission());
remoteSurfaceView = (SurfaceView) view.findViewById(R.id.videocall_video_remote);
remoteSurfaceView.setOnClickListener(
surfaceView -> {
@@ -369,13 +363,7 @@
.translationY(0)
.setInterpolator(linearOutSlowInInterpolator)
.alpha(1)
- .withStartAction(
- new Runnable() {
- @Override
- public void run() {
- switchOnHoldCallController.setOnScreen();
- }
- });
+ .withStartAction(() -> switchOnHoldCallController.setOnScreen());
View contactGridView = contactGridManager.getContainerView();
// Animate contact grid to the shown state.
@@ -385,13 +373,7 @@
.translationY(0)
.setInterpolator(linearOutSlowInInterpolator)
.alpha(1)
- .withStartAction(
- new Runnable() {
- @Override
- public void run() {
- contactGridManager.show();
- }
- });
+ .withStartAction(() -> contactGridManager.show());
endCallButton
.animate()
@@ -399,13 +381,7 @@
.translationY(0)
.setInterpolator(linearOutSlowInInterpolator)
.alpha(1)
- .withStartAction(
- new Runnable() {
- @Override
- public void run() {
- endCallButton.setVisibility(View.VISIBLE);
- }
- })
+ .withStartAction(() -> endCallButton.setVisibility(View.VISIBLE))
.start();
// Animate all the preview controls up to make room for the navigation bar.
@@ -564,13 +540,7 @@
.translationY(offset.y)
.setInterpolator(fastOutLinearInInterpolator)
.alpha(0)
- .withEndAction(
- new Runnable() {
- @Override
- public void run() {
- endCallButton.setVisibility(View.INVISIBLE);
- }
- })
+ .withEndAction(() -> endCallButton.setVisibility(View.INVISIBLE))
.setInterpolator(new FastOutLinearInInterpolator())
.start();
@@ -971,13 +941,7 @@
wasRemoteVideoOff
? R.string.videocall_remote_video_on
: R.string.videocall_remotely_resumed);
- remoteVideoOff.postDelayed(
- new Runnable() {
- @Override
- public void run() {
- remoteVideoOff.setVisibility(View.GONE);
- }
- },
+ remoteVideoOff.postDelayed(() -> remoteVideoOff.setVisibility(View.GONE),
VIDEO_OFF_VIEW_FADE_OUT_DELAY_IN_MILLIS);
} else {
remoteVideoOff.setText(
@@ -1033,13 +997,7 @@
view.setVisibility(View.VISIBLE);
view.animate()
.alpha(endAlpha)
- .withEndAction(
- new Runnable() {
- @Override
- public void run() {
- view.setVisibility(visibility);
- }
- })
+ .withEndAction(() -> view.setVisibility(visibility))
.start();
}
diff --git a/java/com/android/incallui/video/impl/VideoCallFragment.java b/java/com/android/incallui/video/impl/VideoCallFragment.java
index efb98e0..5408af2 100644
--- a/java/com/android/incallui/video/impl/VideoCallFragment.java
+++ b/java/com/android/incallui/video/impl/VideoCallFragment.java
@@ -260,54 +260,24 @@
endCallButton.setOnClickListener(this);
previewTextureView = (TextureView) view.findViewById(R.id.videocall_video_preview);
previewTextureView.setClipToOutline(true);
- previewOffOverlay.setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- checkCameraPermission();
- }
- });
+ previewOffOverlay.setOnClickListener(v -> checkCameraPermission());
remoteTextureView = (TextureView) view.findViewById(R.id.videocall_video_remote);
greenScreenBackgroundView = view.findViewById(R.id.videocall_green_screen_background);
fullscreenBackgroundView = view.findViewById(R.id.videocall_fullscreen_background);
remoteTextureView.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) {
- LogUtil.i("VideoCallFragment.onLayoutChange", "remoteTextureView layout changed");
- updateRemoteVideoScaling();
- updateRemoteOffView();
- }
- });
+ (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
+ LogUtil.i("VideoCallFragment.onLayoutChange", "remoteTextureView layout changed");
+ updateRemoteVideoScaling();
+ updateRemoteOffView();
+ });
previewTextureView.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) {
- LogUtil.i("VideoCallFragment.onLayoutChange", "previewTextureView layout changed");
- updatePreviewVideoScaling();
- updatePreviewOffView();
- }
- });
+ (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
+ LogUtil.i("VideoCallFragment.onLayoutChange", "previewTextureView layout changed");
+ updatePreviewVideoScaling();
+ updatePreviewOffView();
+ });
controls.addOnLayoutChangeListener(
new OnLayoutChangeListener() {
@@ -452,13 +422,7 @@
.translationY(0)
.setInterpolator(linearOutSlowInInterpolator)
.alpha(1)
- .withStartAction(
- new Runnable() {
- @Override
- public void run() {
- controls.setVisibility(View.VISIBLE);
- }
- })
+ .withStartAction(() -> controls.setVisibility(View.VISIBLE))
.start();
// Animate onHold to the shown state.
@@ -468,13 +432,7 @@
.translationY(0)
.setInterpolator(linearOutSlowInInterpolator)
.alpha(1)
- .withStartAction(
- new Runnable() {
- @Override
- public void run() {
- switchOnHoldCallController.setOnScreen();
- }
- });
+ .withStartAction(() -> switchOnHoldCallController.setOnScreen());
View contactGridView = contactGridManager.getContainerView();
// Animate contact grid to the shown state.
@@ -484,13 +442,7 @@
.translationY(0)
.setInterpolator(linearOutSlowInInterpolator)
.alpha(1)
- .withStartAction(
- new Runnable() {
- @Override
- public void run() {
- contactGridManager.show();
- }
- });
+ .withStartAction(() -> contactGridManager.show());
endCallButton
.animate()
@@ -498,13 +450,7 @@
.translationY(0)
.setInterpolator(linearOutSlowInInterpolator)
.alpha(1)
- .withStartAction(
- new Runnable() {
- @Override
- public void run() {
- endCallButton.setVisibility(View.VISIBLE);
- }
- })
+ .withStartAction(() -> endCallButton.setVisibility(View.VISIBLE))
.start();
// Animate all the preview controls up to make room for the navigation bar.
@@ -665,13 +611,7 @@
.translationY(offset.y)
.setInterpolator(fastOutLinearInInterpolator)
.alpha(0)
- .withEndAction(
- new Runnable() {
- @Override
- public void run() {
- endCallButton.setVisibility(View.INVISIBLE);
- }
- })
+ .withEndAction(() -> endCallButton.setVisibility(View.INVISIBLE))
.setInterpolator(new FastOutLinearInInterpolator())
.start();
@@ -1180,13 +1120,7 @@
wasRemoteVideoOff
? R.string.videocall_remote_video_on
: R.string.videocall_remotely_resumed);
- remoteVideoOff.postDelayed(
- new Runnable() {
- @Override
- public void run() {
- remoteVideoOff.setVisibility(View.GONE);
- }
- },
+ remoteVideoOff.postDelayed(() -> remoteVideoOff.setVisibility(View.GONE),
VIDEO_OFF_VIEW_FADE_OUT_DELAY_IN_MILLIS);
} else {
remoteVideoOff.setText(
@@ -1304,13 +1238,7 @@
view.setVisibility(View.VISIBLE);
view.animate()
.alpha(endAlpha)
- .withEndAction(
- new Runnable() {
- @Override
- public void run() {
- view.setVisibility(visibility);
- }
- })
+ .withEndAction(() -> view.setVisibility(visibility))
.start();
}
diff --git a/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java b/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java
index b456f54..4b8f762 100644
--- a/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java
+++ b/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -193,38 +194,34 @@
private void fetchVoicemail(final Network network, final VoicemailStatus.Editor status) {
Executor executor = Executors.newCachedThreadPool();
- executor.execute(
- new Runnable() {
- @Override
- public void run() {
- if (networkCallback != null) {
- networkCallback.waitForIpv4();
+ executor.execute(() -> {
+ if (networkCallback != null) {
+ networkCallback.waitForIpv4();
+ }
+ try {
+ while (retryCount > 0) {
+ VvmLog.i(TAG, "fetching voicemail, retry count=" + retryCount);
+ try (ImapHelper imapHelper =
+ new ImapHelper(context, phoneAccount, network, status)) {
+ boolean success =
+ imapHelper.fetchVoicemailPayload(
+ new VoicemailFetchedCallback(context, uri, phoneAccount), uid);
+ if (!success && retryCount > 0) {
+ VvmLog.i(TAG, "fetch voicemail failed, retrying");
+ retryCount--;
+ } else {
+ return;
}
- try {
- while (retryCount > 0) {
- VvmLog.i(TAG, "fetching voicemail, retry count=" + retryCount);
- try (ImapHelper imapHelper =
- new ImapHelper(context, phoneAccount, network, status)) {
- boolean success =
- imapHelper.fetchVoicemailPayload(
- new VoicemailFetchedCallback(context, uri, phoneAccount), uid);
- if (!success && retryCount > 0) {
- VvmLog.i(TAG, "fetch voicemail failed, retrying");
- retryCount--;
- } else {
- return;
- }
- } catch (InitializingException e) {
- VvmLog.w(TAG, "Can't retrieve Imap credentials ", e);
- return;
- }
- }
- } finally {
- if (networkCallback != null) {
- networkCallback.releaseNetwork();
- }
- }
+ } catch (InitializingException e) {
+ VvmLog.w(TAG, "Can't retrieve Imap credentials ", e);
+ return;
}
- });
+ }
+ } finally {
+ if (networkCallback != null) {
+ networkCallback.releaseNetwork();
+ }
+ }
+ });
}
}
diff --git a/java/com/android/voicemail/impl/scheduling/TaskExecutor.java b/java/com/android/voicemail/impl/scheduling/TaskExecutor.java
index 3968525..e7b3833 100644
--- a/java/com/android/voicemail/impl/scheduling/TaskExecutor.java
+++ b/java/com/android/voicemail/impl/scheduling/TaskExecutor.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -131,19 +132,14 @@
private Job job;
- private final Runnable stopServiceWithDelay =
- new Runnable() {
- @MainThread
- @Override
- public void run() {
- VvmLog.i(TAG, "Stopping service");
- if (!isJobRunning() || isTerminating()) {
- VvmLog.e(TAG, "Service already stopped");
- return;
- }
- scheduleJobAndTerminate(0, true);
- }
- };
+ private final Runnable stopServiceWithDelay = () -> {
+ VvmLog.i(TAG, "Stopping service");
+ if (!isJobRunning() || isTerminating()) {
+ VvmLog.e(TAG, "Service already stopped");
+ return;
+ }
+ scheduleJobAndTerminate(0, true);
+ };
/**
* Reschedule the {@link TaskSchedulerJobService} and terminate the executor when the {@link Job}
@@ -179,7 +175,7 @@
VvmLog.w("JobFinishedPoller.run", "Job still running");
mainThreadHandler.postDelayed(this, TERMINATE_POLLING_INTERVAL_MILLISECONDS);
}
- };
+ }
/** Handles execution of the background task in teh worker thread. */
final class WorkerThreadHandler extends Handler {
@@ -317,14 +313,7 @@
private void sleep(long timeMillis) {
VvmLog.i(TAG, "sleep for " + timeMillis + " millis");
if (timeMillis < SHORT_SLEEP_THRESHOLD_MILLISECONDS) {
- mainThreadHandler.postDelayed(
- new Runnable() {
- @Override
- public void run() {
- maybeRunNextTask();
- }
- },
- timeMillis);
+ mainThreadHandler.postDelayed(() -> maybeRunNextTask(), timeMillis);
return;
}
scheduleJobAndTerminate(timeMillis, false);
diff --git a/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java b/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java
index 1fdf917..b57da66 100644
--- a/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java
+++ b/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java
@@ -164,15 +164,11 @@
*/
Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(
- new Runnable() {
- @Override
- public void run() {
- if (resultReceived == false) {
- onFailed(NETWORK_REQUEST_FAILED_TIMEOUT);
- }
- }
- },
- NETWORK_REQUEST_TIMEOUT_MILLIS);
+ () -> {
+ if (!resultReceived) {
+ onFailed(NETWORK_REQUEST_FAILED_TIMEOUT);
+ }},
+ NETWORK_REQUEST_TIMEOUT_MILLIS);
}
public void releaseNetwork() {