Merge "Implement Font Scaling Quick Settings Tile (3/n)" into tm-qpr-dev am: 002f0ce9c3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21327618 Change-Id: I1070c3b6c524d293c02e143225bf35e8cc489fda Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
27
packages/SystemUI/res/layout/font_scaling_dialog.xml
Normal file
27
packages/SystemUI/res/layout/font_scaling_dialog.xml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?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"/>
|
||||||
@@ -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] -->
|
<!-- 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>
|
<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 -->
|
<!-- Window Magnification strings -->
|
||||||
<!-- Title for Magnification Window [CHAR LIMIT=NONE] -->
|
<!-- Title for Magnification Window [CHAR LIMIT=NONE] -->
|
||||||
<string name="magnification_window_title">Magnification Window</string>
|
<string name="magnification_window_title">Magnification Window</string>
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,8 +19,12 @@ import android.content.Intent
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import com.android.internal.jank.InteractionJankMonitor
|
||||||
import com.android.internal.logging.MetricsLogger
|
import com.android.internal.logging.MetricsLogger
|
||||||
import com.android.systemui.R
|
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.Background
|
||||||
import com.android.systemui.dagger.qualifiers.Main
|
import com.android.systemui.dagger.qualifiers.Main
|
||||||
import com.android.systemui.plugins.ActivityStarter
|
import com.android.systemui.plugins.ActivityStarter
|
||||||
@@ -30,6 +34,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController
|
|||||||
import com.android.systemui.qs.QSHost
|
import com.android.systemui.qs.QSHost
|
||||||
import com.android.systemui.qs.logging.QSLogger
|
import com.android.systemui.qs.logging.QSLogger
|
||||||
import com.android.systemui.qs.tileimpl.QSTileImpl
|
import com.android.systemui.qs.tileimpl.QSTileImpl
|
||||||
|
import com.android.systemui.statusbar.phone.SystemUIDialog
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FontScalingTile
|
class FontScalingTile
|
||||||
@@ -42,7 +47,8 @@ constructor(
|
|||||||
metricsLogger: MetricsLogger,
|
metricsLogger: MetricsLogger,
|
||||||
statusBarStateController: StatusBarStateController,
|
statusBarStateController: StatusBarStateController,
|
||||||
activityStarter: ActivityStarter,
|
activityStarter: ActivityStarter,
|
||||||
qsLogger: QSLogger
|
qsLogger: QSLogger,
|
||||||
|
private val dialogLaunchAnimator: DialogLaunchAnimator
|
||||||
) :
|
) :
|
||||||
QSTileImpl<QSTile.State?>(
|
QSTileImpl<QSTile.State?>(
|
||||||
host,
|
host,
|
||||||
@@ -54,7 +60,7 @@ constructor(
|
|||||||
activityStarter,
|
activityStarter,
|
||||||
qsLogger
|
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 {
|
override fun isAvailable(): Boolean {
|
||||||
return false
|
return false
|
||||||
@@ -66,11 +72,24 @@ constructor(
|
|||||||
return state
|
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?) {
|
override fun handleUpdateState(state: QSTile.State?, arg: Any?) {
|
||||||
state?.label = mContext.getString(R.string.quick_settings_font_scaling_label)
|
state?.label = mContext.getString(R.string.quick_settings_font_scaling_label)
|
||||||
state?.icon = mIcon
|
state?.icon = icon
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLongClickIntent(): Intent? {
|
override fun getLongClickIntent(): Intent? {
|
||||||
@@ -80,4 +99,8 @@ constructor(
|
|||||||
override fun getTileLabel(): CharSequence {
|
override fun getTileLabel(): CharSequence {
|
||||||
return mContext.getString(R.string.quick_settings_font_scaling_label)
|
return mContext.getString(R.string.quick_settings_font_scaling_label)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val INTERACTION_JANK_TAG = "font_scaling"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user