Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialogController.java +1 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ public interface VolumeDialogController { boolean areCaptionsEnabled(); void setCaptionsEnabled(boolean isEnabled); boolean isCaptionStreamOptedOut(); void getCaptionsComponentState(boolean fromTooltip); Loading packages/SystemUI/res/color/caption_tint_color_selector.xml 0 → 100644 +23 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2019 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 --> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sysui="http://schemas.android.com/apk/res-auto"> <item sysui:optedOut="true" android:color="?android:attr/colorButtonNormal"/> <item android:color="?android:attr/colorAccent"/> </selector> No newline at end of file packages/SystemUI/res/layout/volume_dialog.xml +5 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sysui="http://schemas.android.com/apk/res-auto" android:id="@+id/volume_dialog_container" android:layout_width="wrap_content" android:layout_height="wrap_content" Loading Loading @@ -117,16 +118,17 @@ android:clipToPadding="false" android:translationZ="@dimen/volume_dialog_elevation" android:background="@drawable/rounded_bg_full"> <com.android.keyguard.AlphaOptimizedImageButton <com.android.systemui.volume.CaptionsToggleImageButton android:id="@+id/odi_captions_icon" android:src="@drawable/ic_volume_odi_captions_disabled" style="@style/VolumeButtons" android:background="@drawable/rounded_ripple" android:layout_width="match_parent" android:layout_height="match_parent" android:tint="@color/accent_tint_color_selector" android:tint="@color/caption_tint_color_selector" android:layout_gravity="center" android:soundEffectsEnabled="false" /> android:soundEffectsEnabled="false" sysui:optedOut="false"/> </FrameLayout> </LinearLayout> Loading packages/SystemUI/res/values/attrs.xml +4 −0 Original line number Diff line number Diff line Loading @@ -146,5 +146,9 @@ <attr name="showAirplaneMode" format="boolean" /> </declare-styleable> <declare-styleable name="CaptionsToggleImageButton"> <attr name="optedOut" format="boolean" /> </declare-styleable> </resources> packages/SystemUI/src/com/android/systemui/volume/CaptionsToggleImageButton.java 0 → 100644 +67 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.volume; import android.content.Context; import android.util.AttributeSet; import com.android.keyguard.AlphaOptimizedImageButton; import com.android.systemui.R; /** Toggle button in Volume Dialog that allows extra state for when streams are opted-out */ public class CaptionsToggleImageButton extends AlphaOptimizedImageButton { private static final int[] OPTED_OUT_STATE = new int[] { R.attr.optedOut }; private boolean mComponentEnabled = false; private boolean mOptedOut = false; public CaptionsToggleImageButton(Context context, AttributeSet attrs) { super(context, attrs); } @Override public int[] onCreateDrawableState(int extraSpace) { int[] state = super.onCreateDrawableState(extraSpace + 1); if (mOptedOut) { mergeDrawableStates(state, OPTED_OUT_STATE); } return state; } Runnable setComponentEnabled(boolean isComponentEnabled) { this.mComponentEnabled = isComponentEnabled; return this.setImageResourceAsync(this.mComponentEnabled ? R.drawable.ic_volume_odi_captions : R.drawable.ic_volume_odi_captions_disabled); } boolean getComponentEnabled() { return this.mComponentEnabled; } /** Sets whether or not the current stream has opted out of captions */ void setOptedOut(boolean isOptedOut) { this.mOptedOut = isOptedOut; refreshDrawableState(); } boolean getOptedOut() { return this.mOptedOut; } } Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialogController.java +1 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ public interface VolumeDialogController { boolean areCaptionsEnabled(); void setCaptionsEnabled(boolean isEnabled); boolean isCaptionStreamOptedOut(); void getCaptionsComponentState(boolean fromTooltip); Loading
packages/SystemUI/res/color/caption_tint_color_selector.xml 0 → 100644 +23 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2019 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 --> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sysui="http://schemas.android.com/apk/res-auto"> <item sysui:optedOut="true" android:color="?android:attr/colorButtonNormal"/> <item android:color="?android:attr/colorAccent"/> </selector> No newline at end of file
packages/SystemUI/res/layout/volume_dialog.xml +5 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sysui="http://schemas.android.com/apk/res-auto" android:id="@+id/volume_dialog_container" android:layout_width="wrap_content" android:layout_height="wrap_content" Loading Loading @@ -117,16 +118,17 @@ android:clipToPadding="false" android:translationZ="@dimen/volume_dialog_elevation" android:background="@drawable/rounded_bg_full"> <com.android.keyguard.AlphaOptimizedImageButton <com.android.systemui.volume.CaptionsToggleImageButton android:id="@+id/odi_captions_icon" android:src="@drawable/ic_volume_odi_captions_disabled" style="@style/VolumeButtons" android:background="@drawable/rounded_ripple" android:layout_width="match_parent" android:layout_height="match_parent" android:tint="@color/accent_tint_color_selector" android:tint="@color/caption_tint_color_selector" android:layout_gravity="center" android:soundEffectsEnabled="false" /> android:soundEffectsEnabled="false" sysui:optedOut="false"/> </FrameLayout> </LinearLayout> Loading
packages/SystemUI/res/values/attrs.xml +4 −0 Original line number Diff line number Diff line Loading @@ -146,5 +146,9 @@ <attr name="showAirplaneMode" format="boolean" /> </declare-styleable> <declare-styleable name="CaptionsToggleImageButton"> <attr name="optedOut" format="boolean" /> </declare-styleable> </resources>
packages/SystemUI/src/com/android/systemui/volume/CaptionsToggleImageButton.java 0 → 100644 +67 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.volume; import android.content.Context; import android.util.AttributeSet; import com.android.keyguard.AlphaOptimizedImageButton; import com.android.systemui.R; /** Toggle button in Volume Dialog that allows extra state for when streams are opted-out */ public class CaptionsToggleImageButton extends AlphaOptimizedImageButton { private static final int[] OPTED_OUT_STATE = new int[] { R.attr.optedOut }; private boolean mComponentEnabled = false; private boolean mOptedOut = false; public CaptionsToggleImageButton(Context context, AttributeSet attrs) { super(context, attrs); } @Override public int[] onCreateDrawableState(int extraSpace) { int[] state = super.onCreateDrawableState(extraSpace + 1); if (mOptedOut) { mergeDrawableStates(state, OPTED_OUT_STATE); } return state; } Runnable setComponentEnabled(boolean isComponentEnabled) { this.mComponentEnabled = isComponentEnabled; return this.setImageResourceAsync(this.mComponentEnabled ? R.drawable.ic_volume_odi_captions : R.drawable.ic_volume_odi_captions_disabled); } boolean getComponentEnabled() { return this.mComponentEnabled; } /** Sets whether or not the current stream has opted out of captions */ void setOptedOut(boolean isOptedOut) { this.mOptedOut = isOptedOut; refreshDrawableState(); } boolean getOptedOut() { return this.mOptedOut; } }