Loading packages/SystemUI/res/layout/font_scaling_dialog.xml 0 → 100644 +27 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2023 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. --> <com.android.systemui.common.ui.view.SeekBarWithIconButtonsView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/font_scaling_slider" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" app:max="6" app:progress="0" app:iconStartContentDescription="@string/font_scaling_smaller" app:iconEndContentDescription="@string/font_scaling_larger"/> No newline at end of file packages/SystemUI/res/values/strings.xml +8 −0 Original line number Diff line number Diff line Loading @@ -2183,6 +2183,14 @@ <!-- Title of the overlay warning the user to interact with the device or it will go to sleep. [CHAR LIMIT=25] --> <string name="inattentive_sleep_warning_title">Standby</string> <!-- Font scaling --> <!-- Font scaling: Quick Settings dialog title [CHAR LIMIT=30] --> <string name="font_scaling_dialog_title">Font Size</string> <!-- Content Description for the icon button to make fonts smaller. [CHAR LIMIT=30] --> <string name="font_scaling_smaller">Make smaller</string> <!-- Content Description for the icon button to make fonts larger. [CHAR LIMIT=30] --> <string name="font_scaling_larger">Make larger</string> <!-- Window Magnification strings --> <!-- Title for Magnification Window [CHAR LIMIT=NONE] --> <string name="magnification_window_title">Magnification Window</string> Loading packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialog.kt 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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.systemui.accessibility.fontscaling import android.content.Context import android.os.Bundle import android.view.LayoutInflater import com.android.systemui.R import com.android.systemui.statusbar.phone.SystemUIDialog /** The Dialog that contains a seekbar for changing the font size. */ class FontScalingDialog(context: Context) : SystemUIDialog(context) { override fun onCreate(savedInstanceState: Bundle?) { setTitle(R.string.font_scaling_dialog_title) setView(LayoutInflater.from(context).inflate(R.layout.font_scaling_dialog, null)) setPositiveButton( R.string.quick_settings_done, /* onClick = */ null, /* dismissOnClick = */ true ) super.onCreate(savedInstanceState) } } packages/SystemUI/src/com/android/systemui/qs/tiles/FontScalingTile.kt +27 −4 Original line number Diff line number Diff line Loading @@ -19,8 +19,12 @@ import android.content.Intent import android.os.Handler import android.os.Looper import android.view.View import com.android.internal.jank.InteractionJankMonitor import com.android.internal.logging.MetricsLogger import com.android.systemui.R import com.android.systemui.accessibility.fontscaling.FontScalingDialog import com.android.systemui.animation.DialogCuj import com.android.systemui.animation.DialogLaunchAnimator import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.ActivityStarter Loading @@ -30,6 +34,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.qs.QSHost import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.statusbar.phone.SystemUIDialog import javax.inject.Inject class FontScalingTile Loading @@ -42,7 +47,8 @@ constructor( metricsLogger: MetricsLogger, statusBarStateController: StatusBarStateController, activityStarter: ActivityStarter, qsLogger: QSLogger qsLogger: QSLogger, private val dialogLaunchAnimator: DialogLaunchAnimator ) : QSTileImpl<QSTile.State?>( host, Loading @@ -54,7 +60,7 @@ constructor( activityStarter, qsLogger ) { private val mIcon = ResourceIcon.get(R.drawable.ic_qs_font_scaling) private val icon = ResourceIcon.get(R.drawable.ic_qs_font_scaling) override fun isAvailable(): Boolean { return false Loading @@ -66,11 +72,24 @@ constructor( return state } override fun handleClick(view: View?) {} override fun handleClick(view: View?) { mUiHandler.post { val dialog: SystemUIDialog = FontScalingDialog(mContext) if (view != null) { dialogLaunchAnimator.showFromView( dialog, view, DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, INTERACTION_JANK_TAG) ) } else { dialog.show() } } } override fun handleUpdateState(state: QSTile.State?, arg: Any?) { state?.label = mContext.getString(R.string.quick_settings_font_scaling_label) state?.icon = mIcon state?.icon = icon } override fun getLongClickIntent(): Intent? { Loading @@ -80,4 +99,8 @@ constructor( override fun getTileLabel(): CharSequence { return mContext.getString(R.string.quick_settings_font_scaling_label) } companion object { private const val INTERACTION_JANK_TAG = "font_scaling" } } packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/FontScalingTileTest.kt 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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.systemui.qs.tiles.dialog import android.os.Handler import android.testing.AndroidTestingRunner import android.testing.TestableLooper import androidx.test.filters.SmallTest import com.android.internal.logging.MetricsLogger import com.android.systemui.SysuiTestCase import com.android.systemui.animation.DialogLaunchAnimator import com.android.systemui.classifier.FalsingManagerFake import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.qs.QSTileHost import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tiles.FontScalingTile import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @RunWith(AndroidTestingRunner::class) @TestableLooper.RunWithLooper(setAsMainLooper = true) @SmallTest class FontScalingTileTest : SysuiTestCase() { @Mock private lateinit var qsHost: QSTileHost @Mock private lateinit var metricsLogger: MetricsLogger @Mock private lateinit var statusBarStateController: StatusBarStateController @Mock private lateinit var activityStarter: ActivityStarter @Mock private lateinit var qsLogger: QSLogger @Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator private lateinit var testableLooper: TestableLooper private lateinit var fontScalingTile: FontScalingTile @Before fun setUp() { MockitoAnnotations.initMocks(this) testableLooper = TestableLooper.get(this) `when`(qsHost.getContext()).thenReturn(mContext) fontScalingTile = FontScalingTile( qsHost, testableLooper.looper, Handler(testableLooper.looper), FalsingManagerFake(), metricsLogger, statusBarStateController, activityStarter, qsLogger, dialogLaunchAnimator ) fontScalingTile.initialize() } @Test fun isNotAvailable_whenNotSupportedDevice_returnsFalse() { val isAvailable = fontScalingTile.isAvailable() assertThat(isAvailable).isFalse() } } Loading
packages/SystemUI/res/layout/font_scaling_dialog.xml 0 → 100644 +27 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2023 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. --> <com.android.systemui.common.ui.view.SeekBarWithIconButtonsView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/font_scaling_slider" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" app:max="6" app:progress="0" app:iconStartContentDescription="@string/font_scaling_smaller" app:iconEndContentDescription="@string/font_scaling_larger"/> No newline at end of file
packages/SystemUI/res/values/strings.xml +8 −0 Original line number Diff line number Diff line Loading @@ -2183,6 +2183,14 @@ <!-- Title of the overlay warning the user to interact with the device or it will go to sleep. [CHAR LIMIT=25] --> <string name="inattentive_sleep_warning_title">Standby</string> <!-- Font scaling --> <!-- Font scaling: Quick Settings dialog title [CHAR LIMIT=30] --> <string name="font_scaling_dialog_title">Font Size</string> <!-- Content Description for the icon button to make fonts smaller. [CHAR LIMIT=30] --> <string name="font_scaling_smaller">Make smaller</string> <!-- Content Description for the icon button to make fonts larger. [CHAR LIMIT=30] --> <string name="font_scaling_larger">Make larger</string> <!-- Window Magnification strings --> <!-- Title for Magnification Window [CHAR LIMIT=NONE] --> <string name="magnification_window_title">Magnification Window</string> Loading
packages/SystemUI/src/com/android/systemui/accessibility/fontscaling/FontScalingDialog.kt 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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.systemui.accessibility.fontscaling import android.content.Context import android.os.Bundle import android.view.LayoutInflater import com.android.systemui.R import com.android.systemui.statusbar.phone.SystemUIDialog /** The Dialog that contains a seekbar for changing the font size. */ class FontScalingDialog(context: Context) : SystemUIDialog(context) { override fun onCreate(savedInstanceState: Bundle?) { setTitle(R.string.font_scaling_dialog_title) setView(LayoutInflater.from(context).inflate(R.layout.font_scaling_dialog, null)) setPositiveButton( R.string.quick_settings_done, /* onClick = */ null, /* dismissOnClick = */ true ) super.onCreate(savedInstanceState) } }
packages/SystemUI/src/com/android/systemui/qs/tiles/FontScalingTile.kt +27 −4 Original line number Diff line number Diff line Loading @@ -19,8 +19,12 @@ import android.content.Intent import android.os.Handler import android.os.Looper import android.view.View import com.android.internal.jank.InteractionJankMonitor import com.android.internal.logging.MetricsLogger import com.android.systemui.R import com.android.systemui.accessibility.fontscaling.FontScalingDialog import com.android.systemui.animation.DialogCuj import com.android.systemui.animation.DialogLaunchAnimator import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.ActivityStarter Loading @@ -30,6 +34,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.qs.QSHost import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.statusbar.phone.SystemUIDialog import javax.inject.Inject class FontScalingTile Loading @@ -42,7 +47,8 @@ constructor( metricsLogger: MetricsLogger, statusBarStateController: StatusBarStateController, activityStarter: ActivityStarter, qsLogger: QSLogger qsLogger: QSLogger, private val dialogLaunchAnimator: DialogLaunchAnimator ) : QSTileImpl<QSTile.State?>( host, Loading @@ -54,7 +60,7 @@ constructor( activityStarter, qsLogger ) { private val mIcon = ResourceIcon.get(R.drawable.ic_qs_font_scaling) private val icon = ResourceIcon.get(R.drawable.ic_qs_font_scaling) override fun isAvailable(): Boolean { return false Loading @@ -66,11 +72,24 @@ constructor( return state } override fun handleClick(view: View?) {} override fun handleClick(view: View?) { mUiHandler.post { val dialog: SystemUIDialog = FontScalingDialog(mContext) if (view != null) { dialogLaunchAnimator.showFromView( dialog, view, DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, INTERACTION_JANK_TAG) ) } else { dialog.show() } } } override fun handleUpdateState(state: QSTile.State?, arg: Any?) { state?.label = mContext.getString(R.string.quick_settings_font_scaling_label) state?.icon = mIcon state?.icon = icon } override fun getLongClickIntent(): Intent? { Loading @@ -80,4 +99,8 @@ constructor( override fun getTileLabel(): CharSequence { return mContext.getString(R.string.quick_settings_font_scaling_label) } companion object { private const val INTERACTION_JANK_TAG = "font_scaling" } }
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/FontScalingTileTest.kt 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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.systemui.qs.tiles.dialog import android.os.Handler import android.testing.AndroidTestingRunner import android.testing.TestableLooper import androidx.test.filters.SmallTest import com.android.internal.logging.MetricsLogger import com.android.systemui.SysuiTestCase import com.android.systemui.animation.DialogLaunchAnimator import com.android.systemui.classifier.FalsingManagerFake import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.qs.QSTileHost import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tiles.FontScalingTile import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @RunWith(AndroidTestingRunner::class) @TestableLooper.RunWithLooper(setAsMainLooper = true) @SmallTest class FontScalingTileTest : SysuiTestCase() { @Mock private lateinit var qsHost: QSTileHost @Mock private lateinit var metricsLogger: MetricsLogger @Mock private lateinit var statusBarStateController: StatusBarStateController @Mock private lateinit var activityStarter: ActivityStarter @Mock private lateinit var qsLogger: QSLogger @Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator private lateinit var testableLooper: TestableLooper private lateinit var fontScalingTile: FontScalingTile @Before fun setUp() { MockitoAnnotations.initMocks(this) testableLooper = TestableLooper.get(this) `when`(qsHost.getContext()).thenReturn(mContext) fontScalingTile = FontScalingTile( qsHost, testableLooper.looper, Handler(testableLooper.looper), FalsingManagerFake(), metricsLogger, statusBarStateController, activityStarter, qsLogger, dialogLaunchAnimator ) fontScalingTile.initialize() } @Test fun isNotAvailable_whenNotSupportedDevice_returnsFalse() { val isAvailable = fontScalingTile.isAvailable() assertThat(isAvailable).isFalse() } }