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

Commit 0674b9ca authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13184698 from 6d35640b to 25Q2-release

Change-Id: I537e6e4466bcd259e3e26b08f03a766911f7bbd0
parents 190ec16c 6d35640b
Loading
Loading
Loading
Loading
+267 −2

File changed.

Preview size limit exceeded, changes collapsed.

+6 −1
Original line number Diff line number Diff line
@@ -502,6 +502,9 @@
    <!-- The content of a confirmation dialog indicating the impact when the user change the system region. [CHAR LIMIT=NONE]-->
    <string name="desc_notice_device_region_change">Your device will keep %s as a system language</string>
    <!-- The content of a confirmation dialog indicating the impact when the user change the region of the preferred languages. [CHAR LIMIT=NONE]-->
    <string name="desc_notice_device_region_change_for_preferred_language">%1$s will replace %2$s in your preferred languages</string>
    <!-- Title for asking to change system locale or not. [CHAR LIMIT=50]-->
    <string name="title_change_system_locale">Change system language to %s ?</string>
@@ -3588,6 +3591,8 @@
    <string name="storage_wizard_init_v2_external_title">Format SD card for portable storage</string>
    <!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as portable device storage. [CHAR LIMIT=NONE] -->
    <string name="storage_wizard_init_v2_external_summary">Store photos, videos, music, and more and access them from other devices. &lt;a href="https://support.google.com/android/answer/12153449"&gt;Learn more about setting up an SD card&lt;/a&gt;.</string>
    <!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their USB drive as portable device storage. [CHAR LIMIT=NONE] -->
    <string name="storage_wizard_init_v2_external_summary_non_sd_card">Store photos, videos, music, and more and access them from other devices.</string>
    <!-- Button text. A user can tap this button if they want to use their SD card as portable device storage. [CHAR LIMIT=32] -->
    <string name="storage_wizard_init_v2_external_action">Format</string>
    <!-- Button text. A user can tap this button if they want to delay setting up their SD card until a later time. [CHAR LIMIT=32] -->
@@ -3601,7 +3606,7 @@
    <!-- Body of a dialog. This text is confirming that the user wants to use their SD card as portable storage, but the formatting process will erase existing content on the card. The first placeholder is for the name of the device (e.g. a brand name of the SD card or USB drive). The second and third placeholders are for the general references (e.g. SD card, USB drive). [CHAR LIMIT=NONE] -->
    <string name="storage_wizard_format_confirm_v2_body_external">This <xliff:g id="name" example="SanDisk SD card">^1</xliff:g> needs to be formatted to store photos, videos, music, and more.
        \n\nFormatting will erase existing content on the <xliff:g id="name" example="SD card">^2</xliff:g>. To avoid losing content, back it up to another <xliff:g id="name" example="SD card">^3</xliff:g> or device.</string>
    <!-- Button text. If a user taps this button, their SD card or USB device will be formatted and used as extra phone storage. The placeholder is for the specific device (e.g. SD card, USB drive, etc.). [CHAR LIMIT=16] -->
    <!-- Button or title text. If a user taps this button, their SD card or USB device will be formatted and used as extra phone storage. The placeholder is for the specific device (e.g. SD card, USB drive, etc.). [CHAR LIMIT=16] -->
    <string name="storage_wizard_format_confirm_v2_action">Format <xliff:g id="name" example="SD card">^1</xliff:g></string>
    <!-- Title of a full-screen message. This string is confirming that a user wants to move their content to the storage device. They can press a button at the bottom of the screen to move their content. The placeholder is for the specific device (e.g. SD card, USB drive, etc.). [CHAR LIMIT=32] -->
+9 −79
Original line number Diff line number Diff line
@@ -29,10 +29,7 @@ import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.Choreographer;
import android.view.View;
import android.widget.SeekBar;
import android.widget.TextView;
import android.window.DesktopExperienceFlags;

@@ -46,13 +43,10 @@ import androidx.preference.PreferenceGroup;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragmentBase;
import com.android.settings.accessibility.AccessibilitySeekBarPreference;
import com.android.settings.accessibility.DisplaySizeData;
import com.android.settings.accessibility.TextReadingPreferenceFragment;
import com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.DisplayListener;
import com.android.settings.connecteddevice.display.ExternalDisplaySettingsConfiguration.Injector;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.display.DisplayDensityUtils;
import com.android.settingslib.widget.FooterPreference;
import com.android.settingslib.widget.IllustrationPreference;
import com.android.settingslib.widget.MainSwitchPreference;
@@ -352,38 +346,22 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
    }

    @NonNull
    private AccessibilitySeekBarPreference reuseSizePreference(Context context,
            PrefRefresh refresh, int displayId, int position) {
        AccessibilitySeekBarPreference pref =
    private ExternalDisplaySizePreference reuseSizePreference(Context context,
            PrefRefresh refresh, DisplayDevice display, int position) {
        ExternalDisplaySizePreference pref =
                refresh.findUnusedPreference(PrefBasics.EXTERNAL_DISPLAY_SIZE.keyForNth(position));
        if (pref == null) {
            pref = new AccessibilitySeekBarPreference(context, /* attrs= */ null);
            pref.setIconStart(R.drawable.ic_remove_24dp);
            pref.setIconStartContentDescription(R.string.screen_zoom_make_smaller_desc);
            pref.setIconEnd(R.drawable.ic_add_24dp);
            pref.setIconEndContentDescription(R.string.screen_zoom_make_larger_desc);
            pref = new ExternalDisplaySizePreference(context, /* attrs= */ null);
            PrefBasics.EXTERNAL_DISPLAY_SIZE.apply(pref, position);

            setStateForDisplaySizePreference(context, displayId, pref);
        }
        if (display.getMode() != null) {
            pref.setStateForPreference(display.getMode().getPhysicalWidth(),
                    display.getMode().getPhysicalHeight(), display.getId());
        }
        refresh.addPreference(pref);
        return pref;
    }

    private void setStateForDisplaySizePreference(Context context, int displayId,
            AccessibilitySeekBarPreference preference) {
        var displaySizeData = new DisplaySizeData(context,
                new DisplayDensityUtils(context, (info) -> info.displayId == displayId));
        ExternalDisplaySizePreferenceStateHandler seekBarChangeHandler =
                new ExternalDisplaySizePreferenceStateHandler(
                        displaySizeData, preference);

        preference.setMax(displaySizeData.getValues().size() - 1);
        preference.setProgress(displaySizeData.getInitialIndex());
        preference.setContinuousUpdates(false);
        preference.setOnSeekBarChangeListener(seekBarChangeHandler);
    }

    private void update() {
        final var screen = getPreferenceScreen();
        if (screen == null || mInjector == null || mInjector.getContext() == null) {
@@ -587,7 +565,7 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen

    private void addSizePreference(final Context context, PrefRefresh refresh,
            DisplayDevice display, int position) {
        var pref = reuseSizePreference(context, refresh, display.getId(), position);
        var pref = reuseSizePreference(context, refresh, display, position);
        pref.setSummary(EXTERNAL_DISPLAY_SIZE_SUMMARY_RESOURCE);
        pref.setOnPreferenceClickListener(
                (Preference p) -> {
@@ -637,54 +615,6 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
        }
    }

    private static class ExternalDisplaySizePreferenceStateHandler
            implements SeekBar.OnSeekBarChangeListener {
        private static final long MIN_COMMIT_INTERVAL_MS = 800;
        private static final long CHANGE_BY_BUTTON_DELAY_MS = 300;
        private final DisplaySizeData mDisplaySizeData;
        private int mLastDisplayProgress;
        private long mLastCommitTime;
        private final AccessibilitySeekBarPreference mPreference;
        ExternalDisplaySizePreferenceStateHandler(DisplaySizeData displaySizeData,
                AccessibilitySeekBarPreference preference) {
            mDisplaySizeData = displaySizeData;
            mPreference = preference;
        }

        final Choreographer.FrameCallback mCommit = this::tryCommitDisplaySizeConfig;

        private void tryCommitDisplaySizeConfig(long unusedFrameTimeNanos) {
            final int displayProgress = mPreference.getProgress();
            if (displayProgress != mLastDisplayProgress) {
                mDisplaySizeData.commit(displayProgress);
                mLastDisplayProgress = displayProgress;
            }
            mLastCommitTime = SystemClock.elapsedRealtime();
        }

        private void postCommitDelayed() {
            var commitDelayMs = CHANGE_BY_BUTTON_DELAY_MS;
            if (SystemClock.elapsedRealtime() - mLastCommitTime < MIN_COMMIT_INTERVAL_MS) {
                commitDelayMs += MIN_COMMIT_INTERVAL_MS;
            }

            final Choreographer choreographer = Choreographer.getInstance();
            choreographer.removeFrameCallback(mCommit);
            choreographer.postFrameCallbackDelayed(mCommit, commitDelayMs);
        }

        @Override
        public void onProgressChanged(@NonNull SeekBar seekBar, int i, boolean b) {
            postCommitDelayed();
        }

        @Override
        public void onStartTrackingTouch(@NonNull SeekBar seekBar) {}

        @Override
        public void onStopTrackingTouch(@NonNull SeekBar seekBar) {}
    }

    private static class PrefRefresh implements AutoCloseable {
        private final PreferenceGroup mScreen;
        private final HashMap<String, Preference> mUnusedPreferences = new HashMap<>();
+124 −0
Original line number Diff line number Diff line
/*
 * Copyright 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.
 */

package com.android.settings.connecteddevice.display;

import android.content.Context;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.Choreographer;
import android.widget.SeekBar;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.settings.R;
import com.android.settings.accessibility.AccessibilitySeekBarPreference;
import com.android.settings.accessibility.DisplaySizeData;
import com.android.settingslib.display.DisplayDensityUtils;

/**
 * The display size preference setting used for External displays.
 */
public class ExternalDisplaySizePreference extends AccessibilitySeekBarPreference {
    private int mDisplayWidth;
    private int mDisplayHeight;
    private int mDisplayId;
    private Context mContext;

    public ExternalDisplaySizePreference(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
        mDisplayId = -1;
        mDisplayWidth = 0;
        mDisplayHeight = 0;

        setIconStart(R.drawable.ic_remove_24dp);
        setIconStartContentDescription(R.string.screen_zoom_make_smaller_desc);
        setIconEnd(R.drawable.ic_add_24dp);
        setIconEndContentDescription(R.string.screen_zoom_make_larger_desc);
    }

    /** Sets the display width and height for this preference. */
    public void setStateForPreference(int displayWidth, int displayHeight, int displayId) {
        if (mDisplayWidth == displayWidth && mDisplayHeight == displayHeight
                && displayId == mDisplayId) return;
        mDisplayWidth = displayWidth;
        mDisplayHeight = displayHeight;
        mDisplayId = displayId;

        setStateForPreferenceInternal();
    }

    private void setStateForPreferenceInternal() {
        var displaySizeData = new DisplaySizeData(mContext,
                new DisplayDensityUtils(mContext, (info) -> info.displayId == mDisplayId));
        ExternalDisplaySizePreferenceStateHandler
                seekBarChangeHandler =
                new ExternalDisplaySizePreferenceStateHandler(
                        displaySizeData);

        setMax(displaySizeData.getValues().size() - 1);
        setProgress(displaySizeData.getInitialIndex());
        setContinuousUpdates(false);
        setOnSeekBarChangeListener(seekBarChangeHandler);
    }

    private class ExternalDisplaySizePreferenceStateHandler
            implements SeekBar.OnSeekBarChangeListener {
        private static final long MIN_COMMIT_INTERVAL_MS = 800;
        private static final long CHANGE_BY_BUTTON_DELAY_MS = 300;
        private final DisplaySizeData mDisplaySizeData;
        private int mLastDisplayProgress;
        private long mLastCommitTime;
        ExternalDisplaySizePreferenceStateHandler(DisplaySizeData displaySizeData) {
            mDisplaySizeData = displaySizeData;
        }

        final Choreographer.FrameCallback mCommit = this::tryCommitDisplaySizeConfig;

        private void tryCommitDisplaySizeConfig(long unusedFrameTimeNanos) {
            final int displayProgress = getProgress();
            if (displayProgress != mLastDisplayProgress) {
                mDisplaySizeData.commit(displayProgress);
                mLastDisplayProgress = displayProgress;
            }
            mLastCommitTime = SystemClock.elapsedRealtime();
        }

        private void postCommitDelayed() {
            var commitDelayMs = CHANGE_BY_BUTTON_DELAY_MS;
            if (SystemClock.elapsedRealtime() - mLastCommitTime < MIN_COMMIT_INTERVAL_MS) {
                commitDelayMs += MIN_COMMIT_INTERVAL_MS;
            }

            final Choreographer choreographer = Choreographer.getInstance();
            choreographer.removeFrameCallback(mCommit);
            choreographer.postFrameCallbackDelayed(mCommit, commitDelayMs);
        }

        @Override
        public void onProgressChanged(@NonNull SeekBar seekBar, int i, boolean b) {
            postCommitDelayed();
        }

        @Override
        public void onStartTrackingTouch(@NonNull SeekBar seekBar) {}

        @Override
        public void onStopTrackingTouch(@NonNull SeekBar seekBar) {}
    }
}
+15 −7
Original line number Diff line number Diff line
@@ -76,7 +76,10 @@ public class StorageWizardInit extends StorageWizardBase {
        }
        if(mPortable) {
            mFlipper.setDisplayedChild(0);
            setHeaderText(R.string.storage_wizard_init_v2_external_title,
            setHeaderText(
                    ((mDisk != null) && mDisk.isSd())
                            ? R.string.storage_wizard_init_v2_external_title
                            : R.string.storage_wizard_format_confirm_v2_action,
                    getDiskShortDescription());
            setNextButtonText(R.string.storage_wizard_init_v2_external_action);
            setBackButtonText(R.string.wizard_back_adoptable);
@@ -104,7 +107,10 @@ public class StorageWizardInit extends StorageWizardBase {
            v.setEnabled(false);
        } else if (mPortable == false) {
            mFlipper.showNext();
            setHeaderText(R.string.storage_wizard_init_v2_external_title,
            setHeaderText(
                    ((mDisk != null) && mDisk.isSd())
                            ? R.string.storage_wizard_init_v2_external_title
                            : R.string.storage_wizard_format_confirm_v2_action,
                    getDiskShortDescription());
            setNextButtonText(R.string.storage_wizard_init_v2_external_action);
            setBackButtonText(R.string.wizard_back_adoptable);
@@ -151,8 +157,10 @@ public class StorageWizardInit extends StorageWizardBase {
    private void setupHyperlink() {
        TextView external_storage_textview = findViewById(R.id.storage_wizard_init_external_text);
        TextView internal_storage_textview = findViewById(R.id.storage_wizard_init_internal_text);
        String external_storage_text = getResources().getString(R.string.
            storage_wizard_init_v2_external_summary);
        String external_storage_text = getResources().getString(
                ((mDisk != null) && mDisk.isSd())
                        ? R.string.storage_wizard_init_v2_external_summary
                        : R.string.storage_wizard_init_v2_external_summary_non_sd_card);
        String internal_storage_text = getResources().getString(R.string.
            storage_wizard_init_v2_internal_summary);

Loading