Add a new Secure Setting check for current opted-out state of captions.
Bug:129066127 Test: manual Change-Id: I511f5fdb140480ca49e340386d11510f69a5ef31
This commit is contained in:
@@ -60,6 +60,7 @@ public interface VolumeDialogController {
|
||||
|
||||
boolean areCaptionsEnabled();
|
||||
void setCaptionsEnabled(boolean isEnabled);
|
||||
boolean isCaptionStreamOptedOut();
|
||||
|
||||
void getCaptionsComponentState(boolean fromTooltip);
|
||||
|
||||
|
||||
23
packages/SystemUI/res/color/caption_tint_color_selector.xml
Normal file
23
packages/SystemUI/res/color/caption_tint_color_selector.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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>
|
||||
@@ -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"
|
||||
@@ -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>
|
||||
|
||||
@@ -146,5 +146,9 @@
|
||||
<attr name="showAirplaneMode" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="CaptionsToggleImageButton">
|
||||
<attr name="optedOut" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -282,6 +282,13 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
||||
Settings.Secure.ODI_CAPTIONS_ENABLED, isEnabled ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCaptionStreamOptedOut() {
|
||||
int currentValue = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ODI_CAPTIONS_OPTED_OUT, 0);
|
||||
return currentValue == 1;
|
||||
}
|
||||
|
||||
public void getCaptionsComponentState(boolean fromTooltip) {
|
||||
if (mDestroyed) return;
|
||||
mWorker.obtainMessage(W.GET_CAPTIONS_COMPONENT_STATE, fromTooltip).sendToTarget();
|
||||
|
||||
@@ -133,7 +133,7 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
private ViewGroup mRinger;
|
||||
private ImageButton mRingerIcon;
|
||||
private ViewGroup mODICaptionsView;
|
||||
private ImageButton mODICaptionsIcon;
|
||||
private CaptionsToggleImageButton mODICaptionsIcon;
|
||||
private View mSettingsView;
|
||||
private ImageButton mSettingsIcon;
|
||||
private FrameLayout mZenIcon;
|
||||
@@ -587,11 +587,15 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
}
|
||||
|
||||
private void updateCaptionsIcon() {
|
||||
mHandler.post(
|
||||
mODICaptionsIcon.setImageResourceAsync(
|
||||
mController.areCaptionsEnabled()
|
||||
? R.drawable.ic_volume_odi_captions
|
||||
: R.drawable.ic_volume_odi_captions_disabled));
|
||||
boolean componentEnabled = mController.areCaptionsEnabled();
|
||||
if (mODICaptionsIcon.getComponentEnabled() != componentEnabled) {
|
||||
mHandler.post(mODICaptionsIcon.setComponentEnabled(componentEnabled));
|
||||
}
|
||||
|
||||
boolean isOptedOut = mController.isCaptionStreamOptedOut();
|
||||
if (mODICaptionsIcon.getOptedOut() != isOptedOut) {
|
||||
mHandler.post(() -> mODICaptionsIcon.setOptedOut(isOptedOut));
|
||||
}
|
||||
}
|
||||
|
||||
private void onCaptionIconClicked() {
|
||||
@@ -952,7 +956,7 @@ public class VolumeDialogImpl implements VolumeDialog {
|
||||
}
|
||||
|
||||
private void updateVolumeRowH(VolumeRow row) {
|
||||
if (D.BUG) Log.d(TAG, "updateVolumeRowH s=" + row.stream);
|
||||
if (D.BUG) Log.i(TAG, "updateVolumeRowH s=" + row.stream);
|
||||
if (mState == null) return;
|
||||
final StreamState ss = mState.states.get(row.stream);
|
||||
if (ss == null) return;
|
||||
|
||||
Reference in New Issue
Block a user