diff options
5 files changed, 25 insertions, 29 deletions
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index f6d1b7da78f0..9b5f67091a2a 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4532,9 +4532,8 @@ shown in the warning dialog about the accessibility shortcut. --> <string name="color_correction_feature_name">Color Correction</string> - <!-- TODO(b/170970602): remove translatable=false when RBC has official name and strings --> - <!-- Title of Reduce Bright Colors feature, shown in the warning dialog about the accessibility shortcut. [CHAR LIMIT=none] --> - <string name="reduce_bright_colors_feature_name" translatable="false">Reduce Bright Colors</string> + <!-- Title of Reduce Brightness feature, shown in the warning dialog about the accessibility shortcut. [CHAR LIMIT=none] --> + <string name="reduce_bright_colors_feature_name">Reduce Brightness</string> <!-- Text in toast to alert the user that the accessibility shortcut turned on an accessibility service. [CHAR LIMIT=none] --> <string name="accessibility_shortcut_enabling_service">Held volume keys. <xliff:g id="service_name" example="TalkBack">%1$s</xliff:g> turned on.</string> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index d93239531038..589a39c16bcb 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -954,11 +954,8 @@ <string name="quick_settings_dark_mode_secondary_label_on_at">On at <xliff:g id="time" example="10 pm">%s</xliff:g></string> <!-- QuickSettings: Secondary text for when the Dark theme or some other tile will be on until some user-selected time. [CHAR LIMIT=20] --> <string name="quick_settings_dark_mode_secondary_label_until">Until <xliff:g id="time" example="7 am">%s</xliff:g></string> - <!-- TODO(b/170970602): remove translatable=false when RBC has official name and strings --> - <!-- QuickSettings: Label for the toggle that controls whether Reduce Bright Colors is enabled. [CHAR LIMIT=NONE] --> - <string name="quick_settings_reduce_bright_colors_label" translatable="false">Reduce Bright Colors</string> - <!-- QuickSettings: Secondary text for intensity level of Reduce Bright Colors. [CHAR LIMIT=NONE] --> - <string name="quick_settings_reduce_bright_colors_secondary_label" translatable="false"> <xliff:g id="intensity" example="50">%d</xliff:g>%% reduction</string> + <!-- QuickSettings: Label for the toggle that controls whether Reduce Brightness is enabled. [CHAR LIMIT=NONE] --> + <string name="quick_settings_reduce_bright_colors_label">Reduce Brightness</string> <!-- QuickSettings: NFC tile [CHAR LIMIT=NONE] --> <string name="quick_settings_nfc_label">NFC</string> diff --git a/packages/SystemUI/src/com/android/systemui/qs/dagger/QSFlagsModule.java b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSFlagsModule.java index 9ab2d7370ed8..35a8257bd5a7 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/dagger/QSFlagsModule.java +++ b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSFlagsModule.java @@ -16,6 +16,9 @@ package com.android.systemui.qs.dagger; +import android.content.Context; +import android.hardware.display.ColorDisplayManager; + import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.statusbar.FeatureFlags; @@ -27,6 +30,7 @@ import dagger.Provides; @Module public interface QSFlagsModule { String QS_LABELS_FLAG = "qs_labels_flag"; + String RBC_AVAILABLE = "rbc_available"; @Provides @SysUISingleton @@ -34,4 +38,12 @@ public interface QSFlagsModule { static boolean provideQSFlag(FeatureFlags featureFlags) { return featureFlags.isQSLabelsEnabled(); } + + /** */ + @Provides + @SysUISingleton + @Named(RBC_AVAILABLE) + static boolean isReduceBrightColorsAvailable(Context context) { + return ColorDisplayManager.isReduceBrightColorsAvailable(context); + } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ReduceBrightColorsTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ReduceBrightColorsTile.java index 84c7611478cd..f94cabcee297 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ReduceBrightColorsTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ReduceBrightColorsTile.java @@ -16,12 +16,13 @@ package com.android.systemui.qs.tiles; +import static com.android.systemui.qs.dagger.QSFlagsModule.RBC_AVAILABLE; + import android.content.Intent; import android.os.Handler; import android.os.Looper; import android.provider.Settings; import android.service.quicksettings.Tile; -import android.text.TextUtils; import android.widget.Switch; import com.android.internal.logging.MetricsLogger; @@ -39,6 +40,7 @@ import com.android.systemui.settings.UserTracker; import com.android.systemui.util.settings.SecureSettings; import javax.inject.Inject; +import javax.inject.Named; /** Quick settings tile: Reduce Bright Colors **/ public class ReduceBrightColorsTile extends QSTileImpl<QSTile.BooleanState> { @@ -46,9 +48,11 @@ public class ReduceBrightColorsTile extends QSTileImpl<QSTile.BooleanState> { //TODO(b/170973645): get icon drawable private final Icon mIcon = null; private final SecureSetting mActivatedSetting; + private final boolean mIsAvailable; @Inject public ReduceBrightColorsTile( + @Named(RBC_AVAILABLE) boolean isAvailable, QSHost host, @Background Looper backgroundLooper, @Main Handler mainHandler, @@ -69,11 +73,12 @@ public class ReduceBrightColorsTile extends QSTileImpl<QSTile.BooleanState> { refreshState(); } }; + mIsAvailable = isAvailable; + } @Override public boolean isAvailable() { - // TODO(b/170970675): Call into ColorDisplayService to get availability/config status - return true; + return mIsAvailable; } @Override @@ -121,15 +126,6 @@ public class ReduceBrightColorsTile extends QSTileImpl<QSTile.BooleanState> { state.label = mContext.getString(R.string.quick_settings_reduce_bright_colors_label); state.expandedAccessibilityClassName = Switch.class.getName(); state.contentDescription = state.label; - - final int intensity = Settings.Secure.getIntForUser(mContext.getContentResolver(), - Settings.Secure.REDUCE_BRIGHT_COLORS_LEVEL, 0, mActivatedSetting.getCurrentUser()); - state.secondaryLabel = state.value ? mContext.getString( - R.string.quick_settings_reduce_bright_colors_secondary_label, intensity) : ""; - - state.contentDescription = TextUtils.isEmpty(state.secondaryLabel) - ? state.label - : TextUtils.concat(state.label, ", ", state.secondaryLabel); } @Override diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ReduceBrightColorsTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ReduceBrightColorsTileTest.java index 78af20f9db31..ffd747e09e23 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ReduceBrightColorsTileTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ReduceBrightColorsTileTest.java @@ -75,6 +75,7 @@ public class ReduceBrightColorsTileTest extends SysuiTestCase { mFakeSettings = new FakeSettings(); mTile = new ReduceBrightColorsTile( + true, mHost, mTestableLooper.getLooper(), new Handler(mTestableLooper.getLooper()), @@ -95,7 +96,6 @@ public class ReduceBrightColorsTileTest extends SysuiTestCase { assertEquals(Tile.STATE_INACTIVE, mTile.getState().state); assertEquals(mTile.getState().label.toString(), mContext.getString(R.string.quick_settings_reduce_bright_colors_label)); - assertEquals(mTile.getState().secondaryLabel.toString(), ""); } @Test @@ -128,13 +128,5 @@ public class ReduceBrightColorsTileTest extends SysuiTestCase { assertEquals(Tile.STATE_ACTIVE, mTile.getState().state); assertEquals(mTile.getState().label.toString(), mContext.getString(R.string.quick_settings_reduce_bright_colors_label)); - - final int intensity = Settings.Secure.getIntForUser(mContext.getContentResolver(), - Settings.Secure.REDUCE_BRIGHT_COLORS_LEVEL, 0, mUserTracker.getUserId()); - - assertEquals( - mContext.getString( - R.string.quick_settings_reduce_bright_colors_secondary_label, intensity), - mTile.getState().secondaryLabel.toString()); } } |