Merge "Implement Font Scaling Quick Settings Tile (2/n)" into tm-qpr-dev
This commit is contained in:
25
packages/SystemUI/res/drawable/ic_qs_font_scaling.xml
Normal file
25
packages/SystemUI/res/drawable/ic_qs_font_scaling.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M7,20L7,7L2,7L2,4h13v3h-5v13ZM16,20v-8h-3L13,9h9v3h-3v8Z"
|
||||
android:fillColor="#041E49"/>
|
||||
</vector>
|
||||
@@ -81,7 +81,7 @@
|
||||
|
||||
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
|
||||
<string name="quick_settings_tiles_stock" translatable="false">
|
||||
internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream
|
||||
internet,bt,flashlight,dnd,alarm,airplane,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,font_scaling
|
||||
</string>
|
||||
|
||||
<!-- The tiles to display in QuickSettings -->
|
||||
|
||||
@@ -660,6 +660,8 @@
|
||||
<string name="quick_settings_inversion_label">Color inversion</string>
|
||||
<!-- QuickSettings: Label for the toggle that controls whether display color correction is enabled. [CHAR LIMIT=NONE] -->
|
||||
<string name="quick_settings_color_correction_label">Color correction</string>
|
||||
<!-- QuickSettings: Label for font size scaling. [CHAR LIMIT=NONE] -->
|
||||
<string name="quick_settings_font_scaling_label">Font size</string>
|
||||
<!-- QuickSettings: Control panel: Label for button that navigates to user settings. [CHAR LIMIT=NONE] -->
|
||||
<string name="quick_settings_more_user_settings">Manage users</string>
|
||||
<!-- QuickSettings: Control panel: Label for button that dismisses control panel. [CHAR LIMIT=NONE] -->
|
||||
|
||||
@@ -318,4 +318,14 @@
|
||||
<item>Off</item>
|
||||
<item>On</item>
|
||||
</string-array>
|
||||
|
||||
<!-- State names for font scaling tile: unavailable, off, on.
|
||||
This subtitle is shown when the tile is in that particular state but does not set its own
|
||||
subtitle, so some of these may never appear on screen. They should still be translated as
|
||||
if they could appear. [CHAR LIMIT=32] -->
|
||||
<string-array name="tile_states_font_scaling">
|
||||
<item>Unavailable</item>
|
||||
<item>Off</item>
|
||||
<item>On</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -40,6 +40,7 @@ import com.android.systemui.qs.tiles.DeviceControlsTile;
|
||||
import com.android.systemui.qs.tiles.DndTile;
|
||||
import com.android.systemui.qs.tiles.DreamTile;
|
||||
import com.android.systemui.qs.tiles.FlashlightTile;
|
||||
import com.android.systemui.qs.tiles.FontScalingTile;
|
||||
import com.android.systemui.qs.tiles.HotspotTile;
|
||||
import com.android.systemui.qs.tiles.InternetTile;
|
||||
import com.android.systemui.qs.tiles.LocationTile;
|
||||
@@ -94,6 +95,7 @@ public class QSFactoryImpl implements QSFactory {
|
||||
private final Provider<QRCodeScannerTile> mQRCodeScannerTileProvider;
|
||||
private final Provider<OneHandedModeTile> mOneHandedModeTileProvider;
|
||||
private final Provider<DreamTile> mDreamTileProvider;
|
||||
private final Provider<FontScalingTile> mFontScalingTileProvider;
|
||||
|
||||
private final Lazy<QSHost> mQsHostLazy;
|
||||
private final Provider<CustomTile.Builder> mCustomTileBuilderProvider;
|
||||
@@ -129,7 +131,8 @@ public class QSFactoryImpl implements QSFactory {
|
||||
Provider<QRCodeScannerTile> qrCodeScannerTileProvider,
|
||||
Provider<OneHandedModeTile> oneHandedModeTileProvider,
|
||||
Provider<ColorCorrectionTile> colorCorrectionTileProvider,
|
||||
Provider<DreamTile> dreamTileProvider) {
|
||||
Provider<DreamTile> dreamTileProvider,
|
||||
Provider<FontScalingTile> fontScalingTileProvider) {
|
||||
mQsHostLazy = qsHostLazy;
|
||||
mCustomTileBuilderProvider = customTileBuilderProvider;
|
||||
|
||||
@@ -161,6 +164,7 @@ public class QSFactoryImpl implements QSFactory {
|
||||
mOneHandedModeTileProvider = oneHandedModeTileProvider;
|
||||
mColorCorrectionTileProvider = colorCorrectionTileProvider;
|
||||
mDreamTileProvider = dreamTileProvider;
|
||||
mFontScalingTileProvider = fontScalingTileProvider;
|
||||
}
|
||||
|
||||
/** Creates a tile with a type based on {@code tileSpec} */
|
||||
@@ -232,6 +236,8 @@ public class QSFactoryImpl implements QSFactory {
|
||||
return mColorCorrectionTileProvider.get();
|
||||
case "dream":
|
||||
return mDreamTileProvider.get();
|
||||
case "font_scaling":
|
||||
return mFontScalingTileProvider.get();
|
||||
}
|
||||
|
||||
// Custom tiles
|
||||
|
||||
@@ -694,7 +694,8 @@ internal object SubtitleArrayMapping {
|
||||
"alarm" to R.array.tile_states_alarm,
|
||||
"onehanded" to R.array.tile_states_onehanded,
|
||||
"color_correction" to R.array.tile_states_color_correction,
|
||||
"dream" to R.array.tile_states_dream
|
||||
"dream" to R.array.tile_states_dream,
|
||||
"font_scaling" to R.array.tile_states_font_scaling
|
||||
)
|
||||
|
||||
fun getSubtitleId(spec: String?): Int {
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import com.android.internal.logging.MetricsLogger
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.dagger.qualifiers.Background
|
||||
import com.android.systemui.dagger.qualifiers.Main
|
||||
import com.android.systemui.plugins.ActivityStarter
|
||||
import com.android.systemui.plugins.FalsingManager
|
||||
import com.android.systemui.plugins.qs.QSTile
|
||||
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 javax.inject.Inject
|
||||
|
||||
class FontScalingTile
|
||||
@Inject
|
||||
constructor(
|
||||
host: QSHost,
|
||||
@Background backgroundLooper: Looper,
|
||||
@Main mainHandler: Handler,
|
||||
falsingManager: FalsingManager,
|
||||
metricsLogger: MetricsLogger,
|
||||
statusBarStateController: StatusBarStateController,
|
||||
activityStarter: ActivityStarter,
|
||||
qsLogger: QSLogger
|
||||
) :
|
||||
QSTileImpl<QSTile.State?>(
|
||||
host,
|
||||
backgroundLooper,
|
||||
mainHandler,
|
||||
falsingManager,
|
||||
metricsLogger,
|
||||
statusBarStateController,
|
||||
activityStarter,
|
||||
qsLogger
|
||||
) {
|
||||
private val mIcon = ResourceIcon.get(R.drawable.ic_qs_font_scaling)
|
||||
|
||||
override fun isAvailable(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun newTileState(): QSTile.State {
|
||||
val state = QSTile.State()
|
||||
state.handlesLongClick = false
|
||||
return state
|
||||
}
|
||||
|
||||
override fun handleClick(view: View?) {}
|
||||
|
||||
override fun handleUpdateState(state: QSTile.State?, arg: Any?) {
|
||||
state?.label = mContext.getString(R.string.quick_settings_font_scaling_label)
|
||||
state?.icon = mIcon
|
||||
}
|
||||
|
||||
override fun getLongClickIntent(): Intent? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getTileLabel(): CharSequence {
|
||||
return mContext.getString(R.string.quick_settings_font_scaling_label)
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import com.android.systemui.qs.tiles.DeviceControlsTile
|
||||
import com.android.systemui.qs.tiles.DndTile
|
||||
import com.android.systemui.qs.tiles.DreamTile
|
||||
import com.android.systemui.qs.tiles.FlashlightTile
|
||||
import com.android.systemui.qs.tiles.FontScalingTile
|
||||
import com.android.systemui.qs.tiles.HotspotTile
|
||||
import com.android.systemui.qs.tiles.InternetTile
|
||||
import com.android.systemui.qs.tiles.LocationTile
|
||||
@@ -87,7 +88,8 @@ private val specMap = mapOf(
|
||||
"qr_code_scanner" to QRCodeScannerTile::class.java,
|
||||
"onehanded" to OneHandedModeTile::class.java,
|
||||
"color_correction" to ColorCorrectionTile::class.java,
|
||||
"dream" to DreamTile::class.java
|
||||
"dream" to DreamTile::class.java,
|
||||
"font_scaling" to FontScalingTile::class.java
|
||||
)
|
||||
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
@@ -126,6 +128,7 @@ class QSFactoryImplTest : SysuiTestCase() {
|
||||
@Mock private lateinit var oneHandedModeTile: OneHandedModeTile
|
||||
@Mock private lateinit var colorCorrectionTile: ColorCorrectionTile
|
||||
@Mock private lateinit var dreamTile: DreamTile
|
||||
@Mock private lateinit var fontScalingTile: FontScalingTile
|
||||
|
||||
private lateinit var factory: QSFactoryImpl
|
||||
|
||||
@@ -167,7 +170,8 @@ class QSFactoryImplTest : SysuiTestCase() {
|
||||
{ qrCodeScannerTile },
|
||||
{ oneHandedModeTile },
|
||||
{ colorCorrectionTile },
|
||||
{ dreamTile }
|
||||
{ dreamTile },
|
||||
{ fontScalingTile }
|
||||
)
|
||||
// When adding/removing tiles, fix also [specMap]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user