Caption settings cleanup
Bug: 353757664 Test: atest com.android.settings.accessibility Test: Manually verify conditions described in bug Flag: com.android.settings.accessibility.fix_a11y_settings_search Change-Id: Iff25702843e5dd3e7ebcca1a13f190d48cf83e7a
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
@@ -39,6 +40,7 @@ import java.util.List;
|
||||
public class CaptioningCustomController extends BasePreferenceController
|
||||
implements LifecycleObserver, OnStart, OnStop {
|
||||
|
||||
@Nullable
|
||||
private Preference mCustom;
|
||||
private final CaptionHelper mCaptionHelper;
|
||||
private final ContentResolver mContentResolver;
|
||||
@@ -50,32 +52,41 @@ public class CaptioningCustomController extends BasePreferenceController
|
||||
);
|
||||
|
||||
public CaptioningCustomController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mCaptionHelper = new CaptionHelper(context);
|
||||
mContentResolver = context.getContentResolver();
|
||||
mSettingsContentObserver = new AccessibilitySettingsContentObserver(
|
||||
new Handler(Looper.getMainLooper()));
|
||||
mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS,
|
||||
key -> refreshShowingCustom());
|
||||
this(context, preferenceKey, new CaptionHelper(context),
|
||||
new AccessibilitySettingsContentObserver(new Handler(Looper.getMainLooper())));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
CaptioningCustomController(Context context, String preferenceKey,
|
||||
CaptioningCustomController(
|
||||
Context context, String preferenceKey, CaptionHelper captionHelper,
|
||||
AccessibilitySettingsContentObserver contentObserver) {
|
||||
this(context, preferenceKey);
|
||||
super(context, preferenceKey);
|
||||
mCaptionHelper = new CaptionHelper(context);
|
||||
mContentResolver = context.getContentResolver();
|
||||
mSettingsContentObserver = contentObserver;
|
||||
mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS, key -> {
|
||||
if (mCustom != null) {
|
||||
mCustom.setVisible(shouldShowPreference());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
||||
return (shouldShowPreference()) ? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
||||
} else {
|
||||
return AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mCustom = screen.findPreference(getPreferenceKey());
|
||||
refreshShowingCustom();
|
||||
if (mCustom != null) {
|
||||
mCustom.setVisible(shouldShowPreference());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,9 +99,7 @@ public class CaptioningCustomController extends BasePreferenceController
|
||||
mSettingsContentObserver.unregister(mContentResolver);
|
||||
}
|
||||
|
||||
private void refreshShowingCustom() {
|
||||
final boolean isCustomPreset =
|
||||
mCaptionHelper.getRawUserStyle() == CaptioningManager.CaptionStyle.PRESET_CUSTOM;
|
||||
mCustom.setVisible(isCustomPreset);
|
||||
private boolean shouldShowPreference() {
|
||||
return mCaptionHelper.getRawUserStyle() == CaptioningManager.CaptionStyle.PRESET_CUSTOM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,12 @@ package com.android.settings.accessibility;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
@@ -34,14 +36,26 @@ public class CaptioningWindowColorController extends BasePreferenceController
|
||||
private final CaptionHelper mCaptionHelper;
|
||||
private int mCachedNonDefaultOpacity = CaptionStyle.COLOR_UNSPECIFIED;
|
||||
|
||||
public CaptioningWindowColorController(Context context, String preferenceKey) {
|
||||
@VisibleForTesting
|
||||
CaptioningWindowColorController(Context context, String preferenceKey,
|
||||
CaptionHelper captionHelper) {
|
||||
super(context, preferenceKey);
|
||||
mCaptionHelper = new CaptionHelper(context);
|
||||
mCaptionHelper = captionHelper;
|
||||
}
|
||||
|
||||
public CaptioningWindowColorController(Context context, String preferenceKey) {
|
||||
this(context, preferenceKey, new CaptionHelper(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
||||
return (mCaptionHelper.getRawUserStyle()
|
||||
== CaptioningManager.CaptionStyle.PRESET_CUSTOM)
|
||||
? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
||||
} else {
|
||||
return AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,9 +18,11 @@ package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
@@ -31,14 +33,26 @@ public class CaptioningWindowOpacityController extends BasePreferenceController
|
||||
|
||||
private final CaptionHelper mCaptionHelper;
|
||||
|
||||
public CaptioningWindowOpacityController(Context context, String preferenceKey) {
|
||||
@VisibleForTesting
|
||||
CaptioningWindowOpacityController(Context context, String preferenceKey,
|
||||
CaptionHelper captionHelper) {
|
||||
super(context, preferenceKey);
|
||||
mCaptionHelper = new CaptionHelper(context);
|
||||
mCaptionHelper = captionHelper;
|
||||
}
|
||||
|
||||
public CaptioningWindowOpacityController(Context context, String preferenceKey) {
|
||||
this(context, preferenceKey, new CaptionHelper(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
||||
return (mCaptionHelper.getRawUserStyle()
|
||||
== CaptioningManager.CaptionStyle.PRESET_CUSTOM)
|
||||
? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
||||
} else {
|
||||
return AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user