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;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.ui.UiUtils;
/**
* Represents a simple info popup.
......@@ -49,8 +48,8 @@ public class AssistantInfoPopup {
@CalledByNative
public void show(Context context) {
AlertDialog.Builder builder = new UiUtils
.CompatibleAlertDialogBuilder(context,
AlertDialog.Builder builder = new AlertDialog
.Builder(context,
org.chromium.chrome.autofill_assistant.R.style
.Theme_Chromium_AlertDialog)
.setTitle(mTitle)
......@@ -70,4 +69,4 @@ public class AssistantInfoPopup {
}
builder.show();
}
}
\ No newline at end of file
}
......@@ -14,7 +14,6 @@ import androidx.appcompat.app.AlertDialog;
import org.chromium.base.Callback;
import org.chromium.chrome.browser.autofill_assistant.metrics.DropOutReason;
import org.chromium.chrome.browser.autofill_assistant.metrics.OnBoarding;
import org.chromium.ui.UiUtils;
import java.util.Map;
......@@ -33,8 +32,8 @@ class DialogOnboardingCoordinator extends BaseOnboardingCoordinator {
@Override
void initViewImpl(Callback<Boolean> callback) {
mDialog = new UiUtils
.CompatibleAlertDialogBuilder(getContext(),
mDialog = new AlertDialog
.Builder(getContext(),
org.chromium.chrome.autofill_assistant.R.style
.Theme_Chromium_AlertDialog)
.create();
......@@ -63,4 +62,4 @@ class DialogOnboardingCoordinator extends BaseOnboardingCoordinator {
}
destroy();
}
}
\ No newline at end of file
}
......@@ -13,6 +13,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
......@@ -23,7 +24,6 @@ import org.chromium.content.browser.input.PopupItemType;
import org.chromium.content.browser.input.SelectPopupDialog;
import org.chromium.content.browser.input.SelectPopupItem;
import org.chromium.content.browser.picker.InputDialogContainer;
import org.chromium.ui.UiUtils;
import java.util.ArrayList;
import java.util.Collections;
......@@ -140,8 +140,8 @@ public class AssistantViewInteractions {
@CalledByNative
private static void showGenericPopup(View contentView, Context context,
AssistantGenericUiDelegate delegate, String popupIdentifier) {
new UiUtils
.CompatibleAlertDialogBuilder(context,
new AlertDialog
.Builder(context,
org.chromium.chrome.autofill_assistant.R.style.Theme_Chromium_AlertDialog)
.setView(contentView)
.setOnDismissListener(unused -> delegate.onGenericPopupDismissed(popupIdentifier))
......
......@@ -23,7 +23,6 @@ import org.chromium.components.autofill.AutofillPopup;
import org.chromium.components.autofill.AutofillSuggestion;
import org.chromium.content_public.browser.WebContentsAccessibility;
import org.chromium.ui.DropdownItem;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.WindowAndroid;
/**
......@@ -114,14 +113,12 @@ public class AutofillPopupBridge implements AutofillDelegate, DialogInterface.On
@CalledByNative
private void confirmDeletion(String title, String body) {
mDeletionDialog =
new UiUtils
.CompatibleAlertDialogBuilder(mContext, R.style.Theme_Chromium_AlertDialog)
.setTitle(title)
.setMessage(body)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok, this)
.create();
mDeletionDialog = new AlertDialog.Builder(mContext, R.style.Theme_Chromium_AlertDialog)
.setTitle(title)
.setMessage(body)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok, this)
.create();
mDeletionDialog.show();
}
......
......@@ -27,7 +27,6 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.components.dom_distiller.core.DistilledPagePrefs;
import org.chromium.dom_distiller.mojom.FontFamily;
import org.chromium.dom_distiller.mojom.Theme;
import org.chromium.ui.UiUtils;
import java.text.NumberFormat;
import java.util.HashMap;
......@@ -86,8 +85,8 @@ public class DistilledPagePrefsView extends LinearLayout
}
public static void showDialog(Context context) {
AlertDialog.Builder builder = new UiUtils.CompatibleAlertDialogBuilder(
context, R.style.Theme_Chromium_AlertDialog);
AlertDialog.Builder builder =
new AlertDialog.Builder(context, R.style.Theme_Chromium_AlertDialog);
builder.setView(DistilledPagePrefsView.create(context));
builder.show();
}
......
......@@ -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.OfflineItem;
import org.chromium.components.offline_items_collection.OfflineItemState;
import org.chromium.ui.UiUtils;
import java.io.DataOutputStream;
import java.io.File;
......@@ -578,7 +577,7 @@ public class OMADownloadHandler extends BroadcastReceiver {
activity.startActivity(intent);
}
};
new UiUtils.CompatibleAlertDialogBuilder(activity)
new AlertDialog.Builder(activity)
.setTitle(R.string.open_url_post_oma_download)
.setPositiveButton(R.string.ok, clickListener)
.setNegativeButton(R.string.cancel, clickListener)
......
......@@ -12,7 +12,6 @@ import androidx.appcompat.app.AlertDialog;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
import org.chromium.ui.UiUtils;
/**
* A dialog to notify user of network errors while loading WebAPK's start URL.
......@@ -31,8 +30,8 @@ public class WebApkOfflineDialog {
* @param errorMessage
*/
public void show(final Activity activity, String errorMessage) {
AlertDialog.Builder builder = new UiUtils.CompatibleAlertDialogBuilder(
activity, R.style.Theme_Chromium_AlertDialog);
AlertDialog.Builder builder =
new AlertDialog.Builder(activity, R.style.Theme_Chromium_AlertDialog);
builder.setMessage(errorMessage)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
......
......@@ -25,7 +25,6 @@ import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.task.AsyncTask;
import org.chromium.base.task.PostTask;
import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.WindowAndroid;
import java.security.Principal;
......@@ -232,8 +231,8 @@ public class SSLClientCertificateRequest {
* Builds and shows the dialog.
*/
public void show() {
final AlertDialog.Builder builder = new UiUtils.CompatibleAlertDialogBuilder(
mContext, R.style.Theme_Chromium_AlertDialog);
final AlertDialog.Builder builder =
new AlertDialog.Builder(mContext, R.style.Theme_Chromium_AlertDialog);
builder.setTitle(R.string.client_cert_unsupported_title)
.setMessage(R.string.client_cert_unsupported_message)
.setNegativeButton(R.string.close,
......
......@@ -16,7 +16,6 @@ import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import org.chromium.components.browser_ui.widget.text.AlertDialogEditText;
import org.chromium.ui.UiUtils;
/**
* HTTP Authentication Dialog
......@@ -87,19 +86,17 @@ public class LoginPrompt {
TextView explanationView = (TextView) v.findViewById(R.id.explanation);
explanationView.setText(mMessageBody);
mDialog =
new UiUtils
.CompatibleAlertDialogBuilder(mContext, R.style.Theme_Chromium_AlertDialog)
.setTitle(R.string.login_dialog_title)
.setView(v)
.setPositiveButton(R.string.login_dialog_ok_button_label,
(DialogInterface.OnClickListener) (dialog, whichButton)
-> mObserver.proceed(getUsername(), getPassword()))
.setNegativeButton(R.string.cancel,
(DialogInterface.OnClickListener) (dialog,
whichButton) -> mObserver.cancel())
.setOnCancelListener(dialog -> mObserver.cancel())
.create();
mDialog = new AlertDialog.Builder(mContext, R.style.Theme_Chromium_AlertDialog)
.setTitle(R.string.login_dialog_title)
.setView(v)
.setPositiveButton(R.string.login_dialog_ok_button_label,
(DialogInterface.OnClickListener) (dialog, whichButton)
-> mObserver.proceed(getUsername(), getPassword()))
.setNegativeButton(R.string.cancel,
(DialogInterface.OnClickListener) (dialog,
whichButton) -> mObserver.cancel())
.setOnCancelListener(dialog -> mObserver.cancel())
.create();
mDialog.getDelegate().setHandleNativeActionModesEnabled(false);
// Make the IME appear when the dialog is displayed if applicable.
......
......@@ -38,7 +38,6 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils;
import org.chromium.base.PackageManagerUtils;
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.IntentCallback;
......@@ -242,8 +241,8 @@ public class ShareHelper {
final ShareDialogAdapter adapter =
new ShareDialogAdapter(context, manager, resolveInfoList);
AlertDialog.Builder builder = new UiUtils.CompatibleAlertDialogBuilder(
context, R.style.Theme_Chromium_AlertDialog);
AlertDialog.Builder builder =
new AlertDialog.Builder(context, R.style.Theme_Chromium_AlertDialog);
builder.setTitle(context.getString(R.string.share_link_chooser_title));
builder.setAdapter(adapter, null);
......
......@@ -32,6 +32,7 @@ import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
......@@ -54,7 +55,6 @@ import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.content_public.common.ContentUrlConstants;
import org.chromium.content_public.common.Referrer;
import org.chromium.network.mojom.ReferrerPolicy;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.PageTransition;
import org.chromium.ui.base.PermissionCallback;
import org.chromium.url.GURL;
......@@ -1071,7 +1071,7 @@ public class ExternalNavigationHandler {
Context context = mDelegate.getContext();
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)
.setMessage(R.string.external_app_leave_incognito_warning)
.setPositiveButton(R.string.external_app_leave_incognito_leave,
......
......@@ -12,6 +12,7 @@ import android.os.Handler;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import org.chromium.base.Callback;
import org.chromium.base.ContextUtils;
......@@ -31,7 +32,6 @@ import org.chromium.payments.mojom.PaymentMethodData;
import org.chromium.payments.mojom.PaymentOptions;
import org.chromium.payments.mojom.PaymentRequestDetailsUpdate;
import org.chromium.payments.mojom.PaymentShippingOption;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.WindowAndroid;
import java.util.Collections;
......@@ -130,7 +130,7 @@ public class AndroidPaymentApp
denyCallback.onResult(ErrorStrings.ACTIVITY_NOT_FOUND);
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)
.setMessage(R.string.external_payment_app_leave_incognito_warning)
.setPositiveButton(
......
......@@ -5,7 +5,6 @@
package org.chromium.ui;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
......@@ -27,11 +26,8 @@ import android.widget.ListAdapter;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleableRes;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.graphics.drawable.DrawableCompat;
......@@ -415,43 +411,4 @@ public class UiUtils {
}
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