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

Commit d61db249 authored by Candice Lo's avatar Candice Lo Committed by Automerger Merge Worker
Browse files

Merge changes I8e1ab2ed,I3290d8c3,I3b416841 into udc-dev am: 4cf82d04

parents 86ae8e5c 4cf82d04
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1553,6 +1553,9 @@
    <dimen name="status_bar_user_chip_end_margin">12dp</dimen>
    <dimen name="status_bar_user_chip_text_size">12sp</dimen>

    <!-- System UI Dialog -->
    <dimen name="dialog_title_text_size">24sp</dimen>

    <!-- Internet panel related dimensions -->
    <dimen name="internet_dialog_list_max_height">662dp</dimen>
    <!-- The height of the WiFi network in Internet panel. -->
+1 −1
Original line number Diff line number Diff line
@@ -1041,7 +1041,7 @@

    <style name="TextAppearance.Dialog.Title" parent="@android:style/TextAppearance.DeviceDefault.Large">
        <item name="android:textColor">?android:attr/textColorPrimary</item>
        <item name="android:textSize">24sp</item>
        <item name="android:textSize">@dimen/dialog_title_text_size</item>
        <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
        <item name="android:lineHeight">32sp</item>
        <item name="android:gravity">center</item>
+41 −13
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.Bundle
import android.provider.Settings
import android.util.TypedValue
import android.view.LayoutInflater
import android.widget.Button
import android.widget.SeekBar
@@ -49,8 +50,7 @@ class FontScalingDialog(
    private lateinit var seekBarWithIconButtonsView: SeekBarWithIconButtonsView
    private var lastProgress: Int = -1

    private val configuration: Configuration =
        Configuration(context.getResources().getConfiguration())
    private val configuration: Configuration = Configuration(context.resources.configuration)

    override fun onCreate(savedInstanceState: Bundle?) {
        setTitle(R.string.font_scaling_dialog_title)
@@ -84,31 +84,45 @@ class FontScalingDialog(

        seekBarWithIconButtonsView.setOnSeekBarChangeListener(
            object : OnSeekBarChangeListener {
                override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                    if (progress != lastProgress) {
                        if (!fontSizeHasBeenChangedFromTile) {
                            backgroundExecutor.execute { updateSecureSettingsIfNeeded() }
                            fontSizeHasBeenChangedFromTile = true
                        }

                        backgroundExecutor.execute { updateFontScale(strEntryValues[progress]) }
                var isTrackingTouch = false

                        lastProgress = progress
                override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                    if (!isTrackingTouch) {
                        // The seekbar progress is changed by icon buttons
                        changeFontSize(progress)
                    } else {
                        // Provide preview configuration for text instead of changing the system
                        // font scale before users release their finger from the seekbar.
                        createTextPreview(progress)
                    }
                }

                override fun onStartTrackingTouch(seekBar: SeekBar) {
                    // Do nothing
                    isTrackingTouch = true
                }

                override fun onStopTrackingTouch(seekBar: SeekBar) {
                    // Do nothing
                    isTrackingTouch = false
                    changeFontSize(seekBar.progress)
                }
            }
        )
        doneButton.setOnClickListener { dismiss() }
    }

    private fun changeFontSize(progress: Int) {
        if (progress != lastProgress) {
            if (!fontSizeHasBeenChangedFromTile) {
                backgroundExecutor.execute { updateSecureSettingsIfNeeded() }
                fontSizeHasBeenChangedFromTile = true
            }

            backgroundExecutor.execute { updateFontScale(strEntryValues[progress]) }

            lastProgress = progress
        }
    }

    private fun fontSizeValueToIndex(value: Float): Int {
        var lastValue = strEntryValues[0].toFloat()
        for (i in 1 until strEntryValues.size) {
@@ -153,6 +167,20 @@ class FontScalingDialog(
        }
    }

    /** Provides font size preview for text before putting the final settings to the system. */
    fun createTextPreview(index: Int) {
        val previewConfig = Configuration(configuration)
        previewConfig.fontScale = strEntryValues[index].toFloat()

        val previewConfigContext = context.createConfigurationContext(previewConfig)
        previewConfigContext.theme.setTo(context.theme)

        title.setTextSize(
            TypedValue.COMPLEX_UNIT_PX,
            previewConfigContext.resources.getDimension(R.dimen.dialog_title_text_size)
        )
    }

    companion object {
        private const val ON = "1"
        private const val OFF = "0"
+1 −1
Original line number Diff line number Diff line
@@ -291,7 +291,7 @@ object Flags {
    /** Enables Font Scaling Quick Settings tile */
    // TODO(b/269341316): Tracking Bug
    @JvmField
    val ENABLE_FONT_SCALING_TILE = unreleasedFlag(509, "enable_font_scaling_tile", teamfood = false)
    val ENABLE_FONT_SCALING_TILE = unreleasedFlag(509, "enable_font_scaling_tile", teamfood = true)

    /** Enables new QS Edit Mode visual refresh */
    // TODO(b/269787742): Tracking Bug
+73 −4
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.view.SeekBarWithIconButtonsView
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.capture
import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.settings.FakeSettings
import com.android.systemui.util.settings.SecureSettings
import com.android.systemui.util.settings.SystemSettings
@@ -34,6 +36,10 @@ import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations

private const val ON: Int = 1
@@ -53,6 +59,9 @@ class FontScalingDialogTest : SysuiTestCase() {
            .getResources()
            .getStringArray(com.android.settingslib.R.array.entryvalues_font_size)

    @Captor
    private lateinit var seekBarChangeCaptor: ArgumentCaptor<SeekBar.OnSeekBarChangeListener>

    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)
@@ -61,7 +70,7 @@ class FontScalingDialogTest : SysuiTestCase() {
        secureSettings = FakeSettings()
        backgroundExecutor = FakeExecutor(FakeSystemClock())
        fontScalingDialog =
            FontScalingDialog(mContext, systemSettings, secureSettings, backgroundExecutor)
            spy(FontScalingDialog(mContext, systemSettings, secureSettings, backgroundExecutor))
    }

    @Test
@@ -141,4 +150,64 @@ class FontScalingDialogTest : SysuiTestCase() {

        fontScalingDialog.dismiss()
    }

    @Test
    fun dragSeekbar_systemFontSizeSettingsDoesNotChange() {
        val slider: SeekBarWithIconButtonsView = spy(SeekBarWithIconButtonsView(mContext))
        whenever(
                fontScalingDialog.findViewById<SeekBarWithIconButtonsView>(R.id.font_scaling_slider)
            )
            .thenReturn(slider)
        fontScalingDialog.show()
        verify(slider).setOnSeekBarChangeListener(capture(seekBarChangeCaptor))
        val seekBar: SeekBar = slider.findViewById(R.id.seekbar)!!

        // Default seekbar progress for font size is 1, simulate dragging to 0 without
        // releasing the finger.
        seekBarChangeCaptor.value.onStartTrackingTouch(seekBar)
        // Update seekbar progress. This will trigger onProgressChanged in the
        // OnSeekBarChangeListener and the seekbar could get updated progress value
        // in onStopTrackingTouch.
        seekBar.progress = 0
        backgroundExecutor.runAllReady()

        // Verify that the scale of font size remains the default value 1.0f.
        var systemScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f)
        assertThat(systemScale).isEqualTo(1.0f)

        // Simulate releasing the finger from the seekbar.
        seekBarChangeCaptor.value.onStopTrackingTouch(seekBar)
        backgroundExecutor.runAllReady()

        // Verify that the scale of font size has been updated.
        systemScale = systemSettings.getFloat(Settings.System.FONT_SCALE, /* def= */ 1.0f)
        assertThat(systemScale).isEqualTo(fontSizeValueArray[0].toFloat())

        fontScalingDialog.dismiss()
    }

    @Test
    fun dragSeekBar_createTextPreview() {
        val slider: SeekBarWithIconButtonsView = spy(SeekBarWithIconButtonsView(mContext))
        whenever(
                fontScalingDialog.findViewById<SeekBarWithIconButtonsView>(R.id.font_scaling_slider)
            )
            .thenReturn(slider)
        fontScalingDialog.show()
        verify(slider).setOnSeekBarChangeListener(capture(seekBarChangeCaptor))
        val seekBar: SeekBar = slider.findViewById(R.id.seekbar)!!

        // Default seekbar progress for font size is 1, simulate dragging to 0 without
        // releasing the finger
        seekBarChangeCaptor.value.onStartTrackingTouch(seekBar)
        seekBarChangeCaptor.value.onProgressChanged(
            seekBar,
            /* progress= */ 0,
            /* fromUser= */ false
        )
        backgroundExecutor.runAllReady()

        verify(fontScalingDialog).createTextPreview(/* index= */ 0)
        fontScalingDialog.dismiss()
    }
}