Commit 9902dc1c authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Chromium LUCI CQ

Remove no longer needed CompatibleAlertDialogBuilder

CompatibleAlertDialogBuilder workaround is no longer needed due to
androidx.appcompat roll.

BUG=966002

No-Presubmit: true
Change-Id: Ie4c83d2152fd2980207722ad42fd1732c08d893a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2606275
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846436}
parent dd056568
...@@ -11,7 +11,6 @@ import androidx.appcompat.app.AlertDialog; ...@@ -11,7 +11,6 @@ import androidx.appcompat.app.AlertDialog;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.ui.UiUtils;
/** /**
* Represents a simple info popup. * Represents a simple info popup.
...@@ -49,8 +48,8 @@ public class AssistantInfoPopup { ...@@ -49,8 +48,8 @@ public class AssistantInfoPopup {
@CalledByNative @CalledByNative
public void show(Context context) { public void show(Context context) {
AlertDialog.Builder builder = new UiUtils AlertDialog.Builder builder = new AlertDialog
.CompatibleAlertDialogBuilder(context, .Builder(context,
org.chromium.chrome.autofill_assistant.R.style org.chromium.chrome.autofill_assistant.R.style
.Theme_Chromium_AlertDialog) .Theme_Chromium_AlertDialog)
.setTitle(mTitle) .setTitle(mTitle)
...@@ -70,4 +69,4 @@ public class AssistantInfoPopup { ...@@ -70,4 +69,4 @@ public class AssistantInfoPopup {
} }
builder.show(); builder.show();
} }
} }
\ No newline at end of file
...@@ -14,7 +14,6 @@ import androidx.appcompat.app.AlertDialog; ...@@ -14,7 +14,6 @@ import androidx.appcompat.app.AlertDialog;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.chrome.browser.autofill_assistant.metrics.DropOutReason; import org.chromium.chrome.browser.autofill_assistant.metrics.DropOutReason;
import org.chromium.chrome.browser.autofill_assistant.metrics.OnBoarding; import org.chromium.chrome.browser.autofill_assistant.metrics.OnBoarding;
import org.chromium.ui.UiUtils;
import java.util.Map; import java.util.Map;
...@@ -33,8 +32,8 @@ class DialogOnboardingCoordinator extends BaseOnboardingCoordinator { ...@@ -33,8 +32,8 @@ class DialogOnboardingCoordinator extends BaseOnboardingCoordinator {
@Override @Override
void initViewImpl(Callback<Boolean> callback) { void initViewImpl(Callback<Boolean> callback) {
mDialog = new UiUtils mDialog = new AlertDialog
.CompatibleAlertDialogBuilder(getContext(), .Builder(getContext(),
org.chromium.chrome.autofill_assistant.R.style org.chromium.chrome.autofill_assistant.R.style
.Theme_Chromium_AlertDialog) .Theme_Chromium_AlertDialog)
.create(); .create();
...@@ -63,4 +62,4 @@ class DialogOnboardingCoordinator extends BaseOnboardingCoordinator { ...@@ -63,4 +62,4 @@ class DialogOnboardingCoordinator extends BaseOnboardingCoordinator {
} }
destroy(); destroy();
} }
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ import android.view.ViewGroup; ...@@ -13,6 +13,7 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
...@@ -23,7 +24,6 @@ import org.chromium.content.browser.input.PopupItemType; ...@@ -23,7 +24,6 @@ import org.chromium.content.browser.input.PopupItemType;
import org.chromium.content.browser.input.SelectPopupDialog; import org.chromium.content.browser.input.SelectPopupDialog;
import org.chromium.content.browser.input.SelectPopupItem; import org.chromium.content.browser.input.SelectPopupItem;
import org.chromium.content.browser.picker.InputDialogContainer; import org.chromium.content.browser.picker.InputDialogContainer;
import org.chromium.ui.UiUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -140,8 +140,8 @@ public class AssistantViewInteractions { ...@@ -140,8 +140,8 @@ public class AssistantViewInteractions {
@CalledByNative @CalledByNative
private static void showGenericPopup(View contentView, Context context, private static void showGenericPopup(View contentView, Context context,
AssistantGenericUiDelegate delegate, String popupIdentifier) { AssistantGenericUiDelegate delegate, String popupIdentifier) {
new UiUtils new AlertDialog
.CompatibleAlertDialogBuilder(context, .Builder(context,
org.chromium.chrome.autofill_assistant.R.style.Theme_Chromium_AlertDialog) org.chromium.chrome.autofill_assistant.R.style.Theme_Chromium_AlertDialog)
.setView(contentView) .setView(contentView)
.setOnDismissListener(unused -> delegate.onGenericPopupDismissed(popupIdentifier)) .setOnDismissListener(unused -> delegate.onGenericPopupDismissed(popupIdentifier))
......
...@@ -23,7 +23,6 @@ import org.chromium.components.autofill.AutofillPopup; ...@@ -23,7 +23,6 @@ import org.chromium.components.autofill.AutofillPopup;
import org.chromium.components.autofill.AutofillSuggestion; import org.chromium.components.autofill.AutofillSuggestion;
import org.chromium.content_public.browser.WebContentsAccessibility; import org.chromium.content_public.browser.WebContentsAccessibility;
import org.chromium.ui.DropdownItem; import org.chromium.ui.DropdownItem;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
/** /**
...@@ -114,14 +113,12 @@ public class AutofillPopupBridge implements AutofillDelegate, DialogInterface.On ...@@ -114,14 +113,12 @@ public class AutofillPopupBridge implements AutofillDelegate, DialogInterface.On
@CalledByNative @CalledByNative
private void confirmDeletion(String title, String body) { private void confirmDeletion(String title, String body) {
mDeletionDialog = mDeletionDialog = new AlertDialog.Builder(mContext, R.style.Theme_Chromium_AlertDialog)
new UiUtils .setTitle(title)
.CompatibleAlertDialogBuilder(mContext, R.style.Theme_Chromium_AlertDialog) .setMessage(body)
.setTitle(title) .setNegativeButton(R.string.cancel, null)
.setMessage(body) .setPositiveButton(R.string.ok, this)
.setNegativeButton(R.string.cancel, null) .create();
.setPositiveButton(R.string.ok, this)
.create();
mDeletionDialog.show(); mDeletionDialog.show();
} }
......
...@@ -27,7 +27,6 @@ import org.chromium.chrome.browser.profiles.Profile; ...@@ -27,7 +27,6 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.components.dom_distiller.core.DistilledPagePrefs; import org.chromium.components.dom_distiller.core.DistilledPagePrefs;
import org.chromium.dom_distiller.mojom.FontFamily; import org.chromium.dom_distiller.mojom.FontFamily;
import org.chromium.dom_distiller.mojom.Theme; import org.chromium.dom_distiller.mojom.Theme;
import org.chromium.ui.UiUtils;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.HashMap; import java.util.HashMap;
...@@ -86,8 +85,8 @@ public class DistilledPagePrefsView extends LinearLayout ...@@ -86,8 +85,8 @@ public class DistilledPagePrefsView extends LinearLayout
} }
public static void showDialog(Context context) { public static void showDialog(Context context) {
AlertDialog.Builder builder = new UiUtils.CompatibleAlertDialogBuilder( AlertDialog.Builder builder =
context, R.style.Theme_Chromium_AlertDialog); new AlertDialog.Builder(context, R.style.Theme_Chromium_AlertDialog);
builder.setView(DistilledPagePrefsView.create(context)); builder.setView(DistilledPagePrefsView.create(context));
builder.show(); builder.show();
} }
......
...@@ -48,7 +48,6 @@ import org.chromium.components.download.DownloadCollectionBridge; ...@@ -48,7 +48,6 @@ import org.chromium.components.download.DownloadCollectionBridge;
import org.chromium.components.offline_items_collection.LegacyHelpers; import org.chromium.components.offline_items_collection.LegacyHelpers;
import org.chromium.components.offline_items_collection.OfflineItem; import org.chromium.components.offline_items_collection.OfflineItem;
import org.chromium.components.offline_items_collection.OfflineItemState; import org.chromium.components.offline_items_collection.OfflineItemState;
import org.chromium.ui.UiUtils;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File; import java.io.File;
...@@ -578,7 +577,7 @@ public class OMADownloadHandler extends BroadcastReceiver { ...@@ -578,7 +577,7 @@ public class OMADownloadHandler extends BroadcastReceiver {
activity.startActivity(intent); activity.startActivity(intent);
} }
}; };
new UiUtils.CompatibleAlertDialogBuilder(activity) new AlertDialog.Builder(activity)
.setTitle(R.string.open_url_post_oma_download) .setTitle(R.string.open_url_post_oma_download)
.setPositiveButton(R.string.ok, clickListener) .setPositiveButton(R.string.ok, clickListener)
.setNegativeButton(R.string.cancel, clickListener) .setNegativeButton(R.string.cancel, clickListener)
......
...@@ -12,7 +12,6 @@ import androidx.appcompat.app.AlertDialog; ...@@ -12,7 +12,6 @@ import androidx.appcompat.app.AlertDialog;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.ui.UiUtils;
/** /**
* A dialog to notify user of network errors while loading WebAPK's start URL. * A dialog to notify user of network errors while loading WebAPK's start URL.
...@@ -31,8 +30,8 @@ public class WebApkOfflineDialog { ...@@ -31,8 +30,8 @@ public class WebApkOfflineDialog {
* @param errorMessage * @param errorMessage
*/ */
public void show(final Activity activity, String errorMessage) { public void show(final Activity activity, String errorMessage) {
AlertDialog.Builder builder = new UiUtils.CompatibleAlertDialogBuilder( AlertDialog.Builder builder =
activity, R.style.Theme_Chromium_AlertDialog); new AlertDialog.Builder(activity, R.style.Theme_Chromium_AlertDialog);
builder.setMessage(errorMessage) builder.setMessage(errorMessage)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
......
...@@ -25,7 +25,6 @@ import org.chromium.base.annotations.NativeMethods; ...@@ -25,7 +25,6 @@ import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.task.AsyncTask; import org.chromium.base.task.AsyncTask;
import org.chromium.base.task.PostTask; import org.chromium.base.task.PostTask;
import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import java.security.Principal; import java.security.Principal;
...@@ -232,8 +231,8 @@ public class SSLClientCertificateRequest { ...@@ -232,8 +231,8 @@ public class SSLClientCertificateRequest {
* Builds and shows the dialog. * Builds and shows the dialog.
*/ */
public void show() { public void show() {
final AlertDialog.Builder builder = new UiUtils.CompatibleAlertDialogBuilder( final AlertDialog.Builder builder =
mContext, R.style.Theme_Chromium_AlertDialog); new AlertDialog.Builder(mContext, R.style.Theme_Chromium_AlertDialog);
builder.setTitle(R.string.client_cert_unsupported_title) builder.setTitle(R.string.client_cert_unsupported_title)
.setMessage(R.string.client_cert_unsupported_message) .setMessage(R.string.client_cert_unsupported_message)
.setNegativeButton(R.string.close, .setNegativeButton(R.string.close,
......
...@@ -16,7 +16,6 @@ import android.widget.TextView; ...@@ -16,7 +16,6 @@ import android.widget.TextView;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import org.chromium.components.browser_ui.widget.text.AlertDialogEditText; import org.chromium.components.browser_ui.widget.text.AlertDialogEditText;
import org.chromium.ui.UiUtils;
/** /**
* HTTP Authentication Dialog * HTTP Authentication Dialog
...@@ -87,19 +86,17 @@ public class LoginPrompt { ...@@ -87,19 +86,17 @@ public class LoginPrompt {
TextView explanationView = (TextView) v.findViewById(R.id.explanation); TextView explanationView = (TextView) v.findViewById(R.id.explanation);
explanationView.setText(mMessageBody); explanationView.setText(mMessageBody);
mDialog = mDialog = new AlertDialog.Builder(mContext, R.style.Theme_Chromium_AlertDialog)
new UiUtils .setTitle(R.string.login_dialog_title)
.CompatibleAlertDialogBuilder(mContext, R.style.Theme_Chromium_AlertDialog) .setView(v)
.setTitle(R.string.login_dialog_title) .setPositiveButton(R.string.login_dialog_ok_button_label,
.setView(v) (DialogInterface.OnClickListener) (dialog, whichButton)
.setPositiveButton(R.string.login_dialog_ok_button_label, -> mObserver.proceed(getUsername(), getPassword()))
(DialogInterface.OnClickListener) (dialog, whichButton) .setNegativeButton(R.string.cancel,
-> mObserver.proceed(getUsername(), getPassword())) (DialogInterface.OnClickListener) (dialog,
.setNegativeButton(R.string.cancel, whichButton) -> mObserver.cancel())
(DialogInterface.OnClickListener) (dialog, .setOnCancelListener(dialog -> mObserver.cancel())
whichButton) -> mObserver.cancel()) .create();
.setOnCancelListener(dialog -> mObserver.cancel())
.create();
mDialog.getDelegate().setHandleNativeActionModesEnabled(false); mDialog.getDelegate().setHandleNativeActionModesEnabled(false);
// Make the IME appear when the dialog is displayed if applicable. // Make the IME appear when the dialog is displayed if applicable.
......
...@@ -38,7 +38,6 @@ import org.chromium.base.ApiCompatibilityUtils; ...@@ -38,7 +38,6 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.PackageManagerUtils; import org.chromium.base.PackageManagerUtils;
import org.chromium.components.browser_ui.share.ShareParams.TargetChosenCallback; import org.chromium.components.browser_ui.share.ShareParams.TargetChosenCallback;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.base.WindowAndroid.IntentCallback; import org.chromium.ui.base.WindowAndroid.IntentCallback;
...@@ -242,8 +241,8 @@ public class ShareHelper { ...@@ -242,8 +241,8 @@ public class ShareHelper {
final ShareDialogAdapter adapter = final ShareDialogAdapter adapter =
new ShareDialogAdapter(context, manager, resolveInfoList); new ShareDialogAdapter(context, manager, resolveInfoList);
AlertDialog.Builder builder = new UiUtils.CompatibleAlertDialogBuilder( AlertDialog.Builder builder =
context, R.style.Theme_Chromium_AlertDialog); new AlertDialog.Builder(context, R.style.Theme_Chromium_AlertDialog);
builder.setTitle(context.getString(R.string.share_link_chooser_title)); builder.setTitle(context.getString(R.string.share_link_chooser_title));
builder.setAdapter(adapter, null); builder.setAdapter(adapter, null);
......
...@@ -32,6 +32,7 @@ import androidx.annotation.IntDef; ...@@ -32,6 +32,7 @@ import androidx.annotation.IntDef;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
...@@ -54,7 +55,6 @@ import org.chromium.content_public.browser.UiThreadTaskTraits; ...@@ -54,7 +55,6 @@ import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.content_public.common.ContentUrlConstants; import org.chromium.content_public.common.ContentUrlConstants;
import org.chromium.content_public.common.Referrer; import org.chromium.content_public.common.Referrer;
import org.chromium.network.mojom.ReferrerPolicy; import org.chromium.network.mojom.ReferrerPolicy;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.PageTransition; import org.chromium.ui.base.PageTransition;
import org.chromium.ui.base.PermissionCallback; import org.chromium.ui.base.PermissionCallback;
import org.chromium.url.GURL; import org.chromium.url.GURL;
...@@ -1071,7 +1071,7 @@ public class ExternalNavigationHandler { ...@@ -1071,7 +1071,7 @@ public class ExternalNavigationHandler {
Context context = mDelegate.getContext(); Context context = mDelegate.getContext();
if (ContextUtils.activityFromContext(context) == null) return false; if (ContextUtils.activityFromContext(context) == null) return false;
new UiUtils.CompatibleAlertDialogBuilder(context, R.style.Theme_Chromium_AlertDialog) new AlertDialog.Builder(context, R.style.Theme_Chromium_AlertDialog)
.setTitle(R.string.external_app_leave_incognito_warning_title) .setTitle(R.string.external_app_leave_incognito_warning_title)
.setMessage(R.string.external_app_leave_incognito_warning) .setMessage(R.string.external_app_leave_incognito_warning)
.setPositiveButton(R.string.external_app_leave_incognito_leave, .setPositiveButton(R.string.external_app_leave_incognito_leave,
......
...@@ -12,6 +12,7 @@ import android.os.Handler; ...@@ -12,6 +12,7 @@ import android.os.Handler;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
...@@ -31,7 +32,6 @@ import org.chromium.payments.mojom.PaymentMethodData; ...@@ -31,7 +32,6 @@ import org.chromium.payments.mojom.PaymentMethodData;
import org.chromium.payments.mojom.PaymentOptions; import org.chromium.payments.mojom.PaymentOptions;
import org.chromium.payments.mojom.PaymentRequestDetailsUpdate; import org.chromium.payments.mojom.PaymentRequestDetailsUpdate;
import org.chromium.payments.mojom.PaymentShippingOption; import org.chromium.payments.mojom.PaymentShippingOption;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import java.util.Collections; import java.util.Collections;
...@@ -130,7 +130,7 @@ public class AndroidPaymentApp ...@@ -130,7 +130,7 @@ public class AndroidPaymentApp
denyCallback.onResult(ErrorStrings.ACTIVITY_NOT_FOUND); denyCallback.onResult(ErrorStrings.ACTIVITY_NOT_FOUND);
return; return;
} }
new UiUtils.CompatibleAlertDialogBuilder(context, R.style.Theme_Chromium_AlertDialog) new AlertDialog.Builder(context, R.style.Theme_Chromium_AlertDialog)
.setTitle(R.string.external_app_leave_incognito_warning_title) .setTitle(R.string.external_app_leave_incognito_warning_title)
.setMessage(R.string.external_payment_app_leave_incognito_warning) .setMessage(R.string.external_payment_app_leave_incognito_warning)
.setPositiveButton( .setPositiveButton(
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package org.chromium.ui; package org.chromium.ui;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
...@@ -27,11 +26,8 @@ import android.widget.ListAdapter; ...@@ -27,11 +26,8 @@ import android.widget.ListAdapter;
import androidx.annotation.ColorRes; import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.StyleableRes; import androidx.annotation.StyleableRes;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
...@@ -415,43 +411,4 @@ public class UiUtils { ...@@ -415,43 +411,4 @@ public class UiUtils {
} }
rootView.setSystemUiVisibility(systemUiVisibility); rootView.setSystemUiVisibility(systemUiVisibility);
} }
/**
* Extends {@link AlertDialog.Builder} to work around issues in support library. Note that
* any AlertDialogs shown in CustomTabActivity should be created from this class.
*/
public static class CompatibleAlertDialogBuilder extends AlertDialog.Builder {
private final boolean mIsInNightMode;
public CompatibleAlertDialogBuilder(@NonNull Context context) {
super(context);
mIsInNightMode = isInNightMode(context);
}
public CompatibleAlertDialogBuilder(@NonNull Context context, int themeResId) {
super(context, themeResId);
mIsInNightMode = isInNightMode(context);
}
@Override
public AlertDialog create() {
AlertDialog dialog = super.create();
// Sets local night mode state to reflect the night mode state of the owner activity.
// This is to work around an issue in the support library that the dialog night mode
// state is not inheriting the night mode state of the owner activity, and also resets
// the night mode state of the owner activity. See https://crbug.com/966002 for details.
// TODO(https://crbug.com/966101): Remove this class once support library is updated to
// AndroidX.
dialog.getDelegate().setLocalNightMode(mIsInNightMode
? AppCompatDelegate.MODE_NIGHT_YES
: AppCompatDelegate.MODE_NIGHT_NO);
return dialog;
}
private static boolean isInNightMode(Context context) {
return (context.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK)
== Configuration.UI_MODE_NIGHT_YES;
}
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment