Change string of switchbar and installed service category title
Bug: 122897712 Test: Visual Change-Id: I0f56b4b7375e651a74189dd17e6b3bd8b99ccfca
This commit is contained in:
@@ -4685,7 +4685,7 @@
|
|||||||
<!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
|
<!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
|
||||||
<string name="interaction_control_category_title">Interaction controls</string>
|
<string name="interaction_control_category_title">Interaction controls</string>
|
||||||
<!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
|
<!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
|
||||||
<string name="user_installed_services_category_title">Downloaded services</string>
|
<string name="user_installed_services_category_title">Downloaded apps</string>
|
||||||
<!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
|
<!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
|
||||||
<string name="experimental_category_title">Experimental</string>
|
<string name="experimental_category_title">Experimental</string>
|
||||||
<!-- Title for feature flags dashboard where developers can turn on experimental features [CHAR LIMIT=50] -->
|
<!-- Title for feature flags dashboard where developers can turn on experimental features [CHAR LIMIT=50] -->
|
||||||
@@ -4809,7 +4809,7 @@
|
|||||||
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
|
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
|
||||||
<string name="accessibility_touch_vibration_title">Touch feedback</string>
|
<string name="accessibility_touch_vibration_title">Touch feedback</string>
|
||||||
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
|
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
|
||||||
<string name="accessibility_service_master_switch_title">Use service</string>
|
<string name="accessibility_service_master_switch_title">Use <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
|
||||||
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
|
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
|
||||||
<string name="accessibility_daltonizer_master_switch_title">Use color correction</string>
|
<string name="accessibility_daltonizer_master_switch_title">Use color correction</string>
|
||||||
<!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
|
<!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
|
||||||
|
@@ -34,6 +34,7 @@ import androidx.preference.SwitchPreference;
|
|||||||
|
|
||||||
import com.android.internal.accessibility.AccessibilityShortcutController;
|
import com.android.internal.accessibility.AccessibilityShortcutController;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.widget.SwitchBar;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settingslib.search.Indexable;
|
import com.android.settingslib.search.Indexable;
|
||||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||||
@@ -126,6 +127,13 @@ public class AccessibilityShortcutPreferenceFragment extends ToggleFeaturePrefer
|
|||||||
updatePreferences();
|
updatePreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateSwitchBarText(SwitchBar switchBar) {
|
||||||
|
final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
|
||||||
|
getString(R.string.accessibility_global_gesture_preference_title));
|
||||||
|
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
||||||
|
}
|
||||||
|
|
||||||
private void updatePreferences() {
|
private void updatePreferences() {
|
||||||
ContentResolver cr = getContentResolver();
|
ContentResolver cr = getContentResolver();
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
|
@@ -44,6 +44,7 @@ import android.view.accessibility.AccessibilityManager;
|
|||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.password.ConfirmDeviceCredentialActivity;
|
import com.android.settings.password.ConfirmDeviceCredentialActivity;
|
||||||
|
import com.android.settings.widget.SwitchBar;
|
||||||
import com.android.settings.widget.ToggleSwitch;
|
import com.android.settings.widget.ToggleSwitch;
|
||||||
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
|
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
|
||||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||||
@@ -211,6 +212,15 @@ public class ToggleAccessibilityServicePreferenceFragment extends ToggleFeatureP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateSwitchBarText(SwitchBar switchBar) {
|
||||||
|
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
|
||||||
|
final String switchBarText = (info == null) ? "" :
|
||||||
|
getString(R.string.accessibility_service_master_switch_title,
|
||||||
|
info.getResolveInfo().loadLabel(getPackageManager()));
|
||||||
|
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSwitchBarToggleSwitch() {
|
private void updateSwitchBarToggleSwitch() {
|
||||||
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getActivity())
|
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getActivity())
|
||||||
.contains(mComponentName);
|
.contains(mComponentName);
|
||||||
|
@@ -172,6 +172,13 @@ public class ToggleAutoclickPreferenceFragment extends ToggleFeaturePreferenceFr
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateSwitchBarText(SwitchBar switchBar) {
|
||||||
|
final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
|
||||||
|
getString(R.string.accessibility_autoclick_preference_title));
|
||||||
|
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts seek bar preference progress value to autoclick delay associated with it.
|
* Converts seek bar preference progress value to autoclick delay associated with it.
|
||||||
*/
|
*/
|
||||||
|
@@ -105,8 +105,9 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateSwitchBarText(SwitchBar switchBar) {
|
protected void updateSwitchBarText(SwitchBar switchBar) {
|
||||||
switchBar.setSwitchBarText(R.string.accessibility_daltonizer_master_switch_title,
|
final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
|
||||||
R.string.accessibility_daltonizer_master_switch_title);
|
getString(R.string.accessibility_display_daltonizer_preference_title));
|
||||||
|
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initPreferences() {
|
private void initPreferences() {
|
||||||
|
@@ -58,10 +58,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
|
|
||||||
SettingsActivity activity = (SettingsActivity) getActivity();
|
SettingsActivity activity = (SettingsActivity) getActivity();
|
||||||
mSwitchBar = activity.getSwitchBar();
|
mSwitchBar = activity.getSwitchBar();
|
||||||
updateSwitchBarText(mSwitchBar);
|
|
||||||
mToggleSwitch = mSwitchBar.getSwitch();
|
mToggleSwitch = mSwitchBar.getSwitch();
|
||||||
|
|
||||||
onProcessArguments(getArguments());
|
onProcessArguments(getArguments());
|
||||||
|
updateSwitchBarText(mSwitchBar);
|
||||||
|
|
||||||
// Show the "Settings" menu as if it were a preference screen
|
// Show the "Settings" menu as if it were a preference screen
|
||||||
if (mSettingsTitle != null && mSettingsIntent != null) {
|
if (mSettingsTitle != null && mSettingsIntent != null) {
|
||||||
|
@@ -227,6 +227,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
mSwitchBar.removeOnSwitchChangeListener(this);
|
mSwitchBar.removeOnSwitchChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateSwitchBarText(SwitchBar switchBar) {
|
||||||
|
final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
|
||||||
|
getString(R.string.accessibility_screen_magnification_title));
|
||||||
|
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onProcessArguments(Bundle arguments) {
|
protected void onProcessArguments(Bundle arguments) {
|
||||||
super.onProcessArguments(arguments);
|
super.onProcessArguments(arguments);
|
||||||
|
@@ -77,14 +77,12 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
|||||||
private TextView mTextView;
|
private TextView mTextView;
|
||||||
private String mLabel;
|
private String mLabel;
|
||||||
private String mSummary;
|
private String mSummary;
|
||||||
|
private String mOnText;
|
||||||
|
private String mOffText;
|
||||||
@ColorInt
|
@ColorInt
|
||||||
private int mBackgroundColor;
|
private int mBackgroundColor;
|
||||||
@ColorInt
|
@ColorInt
|
||||||
private int mBackgroundActivatedColor;
|
private int mBackgroundActivatedColor;
|
||||||
@StringRes
|
|
||||||
private int mOnTextId;
|
|
||||||
@StringRes
|
|
||||||
private int mOffTextId;
|
|
||||||
|
|
||||||
private boolean mLoggingIntialized;
|
private boolean mLoggingIntialized;
|
||||||
private boolean mDisabledByAdmin;
|
private boolean mDisabledByAdmin;
|
||||||
@@ -178,14 +176,20 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setTextViewLabelAndBackground(boolean isChecked) {
|
public void setTextViewLabelAndBackground(boolean isChecked) {
|
||||||
mLabel = getResources().getString(isChecked ? mOnTextId : mOffTextId);
|
mLabel = isChecked ? mOnText : mOffText;
|
||||||
setBackgroundColor(isChecked ? mBackgroundActivatedColor : mBackgroundColor);
|
setBackgroundColor(isChecked ? mBackgroundActivatedColor : mBackgroundColor);
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSwitchBarText(int onText, int offText) {
|
public void setSwitchBarText(int onTextId, int offTextId) {
|
||||||
mOnTextId = onText;
|
mOnText = getResources().getString(onTextId);
|
||||||
mOffTextId = offText;
|
mOffText = getResources().getString(offTextId);
|
||||||
|
setTextViewLabelAndBackground(isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSwitchBarText(String onText, String offText) {
|
||||||
|
mOnText = onText;
|
||||||
|
mOffText = offText;
|
||||||
setTextViewLabelAndBackground(isChecked());
|
setTextViewLabelAndBackground(isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,6 +84,24 @@ public class SwitchBarTest {
|
|||||||
.isEqualTo(mContext.getString(onText));
|
.isEqualTo(mContext.getString(onText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setCheck_customLabelWithStringType_shouldUpdateTextAndBackground() {
|
||||||
|
final String onText = mContext.getString(
|
||||||
|
R.string.accessibility_service_master_switch_title);
|
||||||
|
final String offText = mContext.getString(
|
||||||
|
R.string.accessibility_service_master_switch_title);
|
||||||
|
final TextView switchBarTextView = ((TextView) mBar.findViewById(R.id.switch_text));
|
||||||
|
|
||||||
|
mBar.setSwitchBarText(onText, offText);
|
||||||
|
|
||||||
|
assertThat(switchBarTextView.getText()).isEqualTo(offText);
|
||||||
|
|
||||||
|
mBar.setChecked(true);
|
||||||
|
|
||||||
|
assertThat(mBar.getBackground()).isInstanceOf(ColorDrawable.class);
|
||||||
|
assertThat(switchBarTextView.getText()).isEqualTo(onText);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void disabledByAdmin_shouldDelegateToRestrictedIcon() {
|
public void disabledByAdmin_shouldDelegateToRestrictedIcon() {
|
||||||
mBar.setDisabledByAdmin(new EnforcedAdmin());
|
mBar.setDisabledByAdmin(new EnforcedAdmin());
|
||||||
|
Reference in New Issue
Block a user