Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc23c5ee authored by Sooraj Sasindran's avatar Sooraj Sasindran
Browse files

Use dark theme for alerts if device is in dark mode

Use dark theme for alerts if device is in dark mode

Test: verified using system test
Bug: 185578417
Change-Id: I94f4913deaf1237fa6402bb26bef4e3b320ff9ac
parent 4dffc62f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2193,7 +2193,7 @@ public class CallsManager extends Call.ListenerBase
     * @param callId The ID of the call to show the redirection dialog for.
     */
    private void showRedirectionDialog(@NonNull String callId, @NonNull CharSequence appName) {
        AlertDialog confirmDialog = new AlertDialog.Builder(mContext).create();
        AlertDialog confirmDialog = FrameworksUtils.makeAlertDialogBuilder(mContext).create();
        LayoutInflater layoutInflater = LayoutInflater.from(mContext);
        View dialogView = layoutInflater.inflate(R.layout.call_redirection_confirm_dialog, null);

+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.telecom;

import android.app.AlertDialog;
import android.content.Context;
import android.content.res.Configuration;

/**
 * This class provides utility functions over framework APIs
 */
public class FrameworksUtils {
    /**
     * Create a new instance of {@link AlertDialog.Builder}.
     * @param context reference to a Context
     * @return an instance of AlertDialog.Builder
     */
    public static AlertDialog.Builder makeAlertDialogBuilder(Context context) {
        boolean isDarkTheme = (context.getResources().getConfiguration().uiMode
                & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
        return new AlertDialog.Builder(context, isDarkTheme
                ? android.R.style.Theme_DeviceDefault_Dialog_Alert : 0);
    }
}
 No newline at end of file
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.telecom.components;

import com.android.server.telecom.FrameworksUtils;
import com.android.server.telecom.R;

import android.app.Activity;
@@ -84,7 +85,7 @@ public class ErrorDialogActivity extends Activity {
            }
        };

        final AlertDialog errorDialog = new AlertDialog.Builder(this)
        final AlertDialog errorDialog = FrameworksUtils.makeAlertDialogBuilder(this)
                .setMessage(msg).setPositiveButton(android.R.string.ok, clickListener)
                        .setOnCancelListener(cancelListener).create();

@@ -97,7 +98,7 @@ public class ErrorDialogActivity extends Activity {
    }

    private void showMissingVoicemailErrorDialog() {
        new AlertDialog.Builder(this)
        FrameworksUtils.makeAlertDialogBuilder(this)
                .setTitle(R.string.no_vm_number)
                .setMessage(R.string.no_vm_number_msg)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+2 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.server.telecom.FrameworksUtils;
import com.android.server.telecom.R;


@@ -247,7 +248,7 @@ public class BlockedNumbersActivity extends ListActivity
        final EditText editText = (EditText) dialogView.findViewById(R.id.add_blocked_number);
        editText.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
        editText.addTextChangedListener(this);
        AlertDialog dialog = new AlertDialog.Builder(this)
        AlertDialog dialog = FrameworksUtils.makeAlertDialogBuilder(this)
                .setView(dialogView)
                .setPositiveButton(R.string.block_button, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
+2 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.view.View;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

import com.android.server.telecom.FrameworksUtils;
import com.android.server.telecom.R;

public class BlockedNumbersAdapter extends SimpleCursorAdapter {
@@ -72,7 +73,7 @@ public class BlockedNumbersAdapter extends SimpleCursorAdapter {
        Spannable messageSpannable = new SpannableString(message);
        PhoneNumberUtils.addTtsSpan(messageSpannable, startingPosition,
                startingPosition + formattedNumber.length());
        AlertDialog dialog = new AlertDialog.Builder(context)
        AlertDialog dialog = FrameworksUtils.makeAlertDialogBuilder(context)
                .setMessage(messageSpannable)
                .setPositiveButton(R.string.unblock_button,
                        new DialogInterface.OnClickListener() {
Loading