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

Commit 3f71c824 authored by Zoey Chen's avatar Zoey Chen Committed by Android (Google) Code Review
Browse files

Merge "Revert "[Settings] Apply new style to dialog"" into main

parents edcaca17 5c510eb0
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<!--
    Copyright (C) 2016 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp"
        android:height="24dp" android:viewportWidth="960" android:viewportHeight="960"
        android:tint="?android:attr/colorControlNormal">
    <path android:fillColor="@android:color/white"
          android:pathData="M480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,473 799.5,465.5Q799,458 799,453Q794,482 772,501Q750,520 720,520L640,520Q607,520 583.5,496.5Q560,473 560,440L560,400L400,400L400,320Q400,287 423.5,263.5Q447,240 480,240L520,240L520,240Q520,217 532.5,199.5Q545,182 563,171Q543,166 522.5,163Q502,160 480,160Q346,160 253,253Q160,346 160,480Q160,480 160,480Q160,480 160,480L360,480Q426,480 473,527Q520,574 520,640L520,680L400,680L400,790Q420,795 439.5,797.5Q459,800 480,800Z"/>
</vector>
 No newline at end of file
+0 −25
Original line number Diff line number Diff line
<!--
    Copyright (C) 2025 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="32dp"
        android:height="32dp"
        android:viewportWidth="960"
        android:viewportHeight="960"
        android:tint="?android:attr/colorControlNormal">
    <path
        android:fillColor="@android:color/white"
        android:pathData="M480,880Q396.67,880 323.67,848.5Q250.67,817 196.5,762.83Q142.33,708.67 111.17,635.33Q80,562 80,478.67Q80,395 111.17,322.5Q142.33,250 196.5,195.83Q250.67,141.67 323.67,110.83Q396.67,80 480,80Q563.67,80 636.5,110.83Q709.33,141.67 763.5,195.83Q817.67,250 848.83,322.5Q880,395 880,478.67Q880,562 848.83,635.33Q817.67,708.67 763.5,762.83Q709.33,817 636.5,848.5Q563.67,880 480,880ZM480,814Q512,778 534,734Q556,690 570,632.67L390.67,632.67Q404,687.33 426,732.33Q448,777.33 480,814ZM388.67,800.67Q366,764.33 349.5,723.17Q333,682 322,632.67L182.67,632.67Q217.67,696.67 265.5,736Q313.33,775.33 388.67,800.67ZM572,800Q638.67,778.67 691.5,735.67Q744.33,692.67 777.33,632.67L638.67,632.67Q627,681.33 610.83,722.5Q594.67,763.67 572,800ZM158,566L309.33,566Q306.33,541.33 305.5,520.5Q304.67,499.67 304.67,478.67Q304.67,455 305.83,435.5Q307,416 310,393.33L158,393.33Q151.67,416 149.17,435.17Q146.67,454.33 146.67,478.67Q146.67,503 149.17,523.17Q151.67,543.33 158,566ZM377.33,566L583.33,566Q587,538.67 588.17,519.17Q589.33,499.67 589.33,478.67Q589.33,458.33 588.17,439.5Q587,420.67 583.33,393.33L377.33,393.33Q373.67,420.67 372.5,439.5Q371.33,458.33 371.33,478.67Q371.33,499.67 372.5,519.17Q373.67,538.67 377.33,566ZM650,566L802,566Q808.33,543.33 810.83,523.17Q813.33,503 813.33,478.67Q813.33,454.33 810.83,435.17Q808.33,416 802,393.33L650.67,393.33Q653.67,423.33 654.83,442.17Q656,461 656,478.67Q656,500.33 654.5,519.83Q653,539.33 650,566ZM638,326.67L777.33,326.67Q745.67,264 692.83,221Q640,178 571.33,159.33Q594,195 610.17,235.5Q626.33,276 638,326.67ZM390.67,326.67L570.67,326.67Q559.33,276.67 535.67,230.67Q512,184.67 480,147.33Q450,177.33 429,219.67Q408,262 390.67,326.67ZM182.67,326.67L322.67,326.67Q333,278 348.83,237.83Q364.67,197.67 388,160Q319.33,178.67 267.5,221Q215.67,263.33 182.67,326.67Z"/>
</vector>
+1 −2
Original line number Diff line number Diff line
@@ -41,8 +41,7 @@
                android:layout_width="@dimen/admin_details_dialog_icon_size"
                android:layout_height="@dimen/admin_details_dialog_icon_size"
                android:scaleType="fitCenter"
                android:src="@drawable/ic_settings_language"
                android:tint="#4F8438"
                android:src="@drawable/ic_settings_globe"
                android:contentDescription="@null"/>
            <TextView
                android:id="@+id/dialog_title"
+0 −6
Original line number Diff line number Diff line
@@ -558,10 +558,4 @@
    <dimen name="display_block_padding">5dp</dimen>
    <dimen name="display_block_highlight_width">2dp</dimen>
    <dimen name="display_block_corner_radius">10dp</dimen>

    <!-- Locale Picker -->
    <dimen name="locale_picker_dialog_icon_padding">10dp</dimen>
    <dimen name="locale_picker_dialog_title_padding">16dp</dimen>
    <dimen name="locale_picker_dialog_message_padding_left_right">24dp</dimen>
    <dimen name="locale_picker_dialog_message_padding_bottom">32dp</dimen>
</resources>
+51 −53
Original line number Diff line number Diff line
@@ -26,18 +26,22 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;

import com.android.internal.app.LocaleStore;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.utils.CustomDialogHelper;

/**
 * Create a dialog for system locale events.
@@ -55,6 +59,8 @@ public class LocaleDialogFragment extends InstrumentedDialogFragment {
    static final String ARG_SHOW_DIALOG_FOR_NOT_TRANSLATED = "arg_show_dialog_for_not_translated";

    private boolean mShouldKeepDialog;
    @SuppressWarnings("NullAway")
    private AlertDialog mAlertDialog;
    private OnBackInvokedDispatcher mBackDispatcher;

    private OnBackInvokedCallback mBackCallback = () -> {
@@ -102,53 +108,45 @@ public class LocaleDialogFragment extends InstrumentedDialogFragment {
        LocaleListEditor parentFragment = (LocaleListEditor) getParentFragment();
        LocaleDialogController controller = getLocaleDialogController(getContext(), this,
                parentFragment);
        Dialog dialog = createDialog(getContext(), controller);
        dialog.setCanceledOnTouchOutside(false);
        getOnBackInvokedDispatcher(dialog).registerOnBackInvokedCallback(PRIORITY_DEFAULT,
                mBackCallback);
        dialog.setOnDismissListener(dialogInterface -> {
            getOnBackInvokedDispatcher(dialog).unregisterOnBackInvokedCallback(
        LocaleDialogController.DialogContent dialogContent = controller.getDialogContent();
        ViewGroup viewGroup = (ViewGroup) LayoutInflater.from(getContext()).inflate(
                R.layout.locale_dialog, null);
        setDialogTitle(viewGroup, dialogContent.mTitle);
        setDialogMessage(viewGroup, dialogContent.mMessage);

        AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
                .setView(viewGroup);
        if (!dialogContent.mPositiveButton.isEmpty()) {
            builder.setPositiveButton(dialogContent.mPositiveButton, controller);
        }
        if (!dialogContent.mNegativeButton.isEmpty()) {
            builder.setNegativeButton(dialogContent.mNegativeButton, controller);
        }
        mAlertDialog = builder.create();
        getOnBackInvokedDispatcher().registerOnBackInvokedCallback(PRIORITY_DEFAULT, mBackCallback);
        mAlertDialog.setCanceledOnTouchOutside(false);
        mAlertDialog.setOnDismissListener(dialogInterface -> {
            mAlertDialog.getOnBackInvokedDispatcher().unregisterOnBackInvokedCallback(
                            mBackCallback);
        });

        return dialog;
        return mAlertDialog;
    }

    private Dialog createDialog(Context context, LocaleDialogController controller) {
        CustomDialogHelper dialogHelper = new CustomDialogHelper(context);
        LocaleDialogController.DialogContent dialogContent = controller.getDialogContent();
        dialogHelper.setIcon(context.getDrawable(R.drawable.ic_settings_language_32dp))
                .setTitle(dialogContent.mTitle)
                .setMessage(dialogContent.mMessage)
                .setIconPadding(0,
                        context.getResources().getDimensionPixelSize(
                                R.dimen.locale_picker_dialog_icon_padding),
                        0, 0)
                .setTitlePadding(0,
                        context.getResources().getDimensionPixelSize(
                                R.dimen.locale_picker_dialog_title_padding),
                        0,
                        context.getResources().getDimensionPixelSize(
                                R.dimen.locale_picker_dialog_title_padding))
                .setMessagePadding(context.getResources().getDimensionPixelSize(
                                R.dimen.locale_picker_dialog_message_padding_left_right), 0,
                        context.getResources().getDimensionPixelSize(
                                R.dimen.locale_picker_dialog_message_padding_left_right),
                        context.getResources().getDimensionPixelSize(
                                R.dimen.locale_picker_dialog_message_padding_bottom))
                .setPositiveButton(dialogContent.mPositiveButton,
                        view -> {
                            controller.onClick(dialogHelper.getDialog(),
                                    DialogInterface.BUTTON_POSITIVE);
                            dialogHelper.getDialog().dismiss();
                        });
        if (dialogContent.mNegativeButton != 0) {
            dialogHelper.setBackButton(dialogContent.mNegativeButton, view -> {
                controller.onClick(dialogHelper.getDialog(), DialogInterface.BUTTON_NEGATIVE);
                dialogHelper.getDialog().dismiss();
            });
    private static void setDialogTitle(View root, String content) {
        TextView titleView = root.findViewById(R.id.dialog_title);
        if (titleView == null) {
            return;
        }
        titleView.setText(content);
    }

    private static void setDialogMessage(View root, String content) {
        TextView textView = root.findViewById(R.id.dialog_msg);
        if (textView == null) {
            return;
        }
        return dialogHelper.getDialog();
        textView.setText(content);
    }

    @VisibleForTesting
@@ -162,11 +160,11 @@ public class LocaleDialogFragment extends InstrumentedDialogFragment {
    }

    @VisibleForTesting
    public @NonNull OnBackInvokedDispatcher getOnBackInvokedDispatcher(@NonNull Dialog dialog) {
    public @NonNull OnBackInvokedDispatcher getOnBackInvokedDispatcher() {
        if (mBackDispatcher != null) {
            return mBackDispatcher;
        } else {
            return dialog.getOnBackInvokedDispatcher();
            return mAlertDialog.getOnBackInvokedDispatcher();
        }
    }

@@ -230,15 +228,15 @@ public class LocaleDialogFragment extends InstrumentedDialogFragment {
                            R.string.title_change_system_locale), mLocaleInfo.getFullNameNative());
                    dialogContent.mMessage = mContext.getString(
                            R.string.desc_notice_device_locale_settings_change);
                    dialogContent.mPositiveButton =
                            R.string.button_label_confirmation_of_system_locale_change;
                    dialogContent.mNegativeButton = R.string.cancel;
                    dialogContent.mPositiveButton = mContext.getString(
                            R.string.button_label_confirmation_of_system_locale_change);
                    dialogContent.mNegativeButton = mContext.getString(R.string.cancel);
                    break;
                case DIALOG_NOT_AVAILABLE_LOCALE:
                    dialogContent.mTitle = String.format(mContext.getString(
                            R.string.title_unavailable_locale), mLocaleInfo.getFullNameNative());
                    dialogContent.mMessage = mContext.getString(R.string.desc_unavailable_locale);
                    dialogContent.mPositiveButton = R.string.okay;
                    dialogContent.mPositiveButton = mContext.getString(R.string.okay);
                    break;
                case DIALOG_ADD_SYSTEM_LOCALE:
                    dialogContent.mTitle = String.format(mContext.getString(
@@ -246,8 +244,8 @@ public class LocaleDialogFragment extends InstrumentedDialogFragment {
                            mLocaleInfo.getFullNameNative());
                    dialogContent.mMessage = mContext.getString(
                            R.string.desc_system_locale_addition);
                    dialogContent.mPositiveButton = R.string.add;
                    dialogContent.mNegativeButton = R.string.cancel;
                    dialogContent.mPositiveButton = mContext.getString(R.string.add);
                    dialogContent.mNegativeButton = mContext.getString(R.string.cancel);
                    break;
                default:
                    break;
@@ -259,8 +257,8 @@ public class LocaleDialogFragment extends InstrumentedDialogFragment {
        static class DialogContent {
            String mTitle = "";
            String mMessage = "";
            int mPositiveButton = 0;
            int mNegativeButton = 0;
            String mPositiveButton = "";
            String mNegativeButton = "";
        }
    }
}
Loading