Provides TC ID for accessibility framework feature for "shortcut" part

Goal: Improve readability which is a bit difficult because of string concatenation for accurate translation.
Root cause: In some locales, framework features name would be a word rather than a product name. Hence it need to be in the different position in a sentence.
Solution: Use whole sentence to translate instead of concatenating the string could solve this issue.

Bug: 185478543
Test: Manually testing
Change-Id: I5a0f04e7ab0d7aa789e10ce6f611cde9bf3660c1
This commit is contained in:
menghanli
2021-07-02 16:07:30 +08:00
committed by Menghan Li
parent 2ddfd5616d
commit a606c43adf
7 changed files with 37 additions and 13 deletions

View File

@@ -55,7 +55,6 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.password.ConfirmDeviceCredentialActivity;
import com.android.settings.widget.SettingsMainSwitchPreference;
import com.android.settingslib.accessibility.AccessibilityUtils;
import java.util.List;
@@ -221,15 +220,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
mComponentName);
}
@Override
protected void updateToggleServiceTitle(SettingsMainSwitchPreference switchPreference) {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
final String switchBarText = (info == null) ? "" :
getString(R.string.accessibility_service_primary_switch_title,
info.getResolveInfo().loadLabel(getPackageManager()));
switchPreference.setTitle(switchBarText);
}
@Override
protected void updateSwitchBarToggleSwitch() {
final boolean checked = isAccessibilityServiceEnabled();

View File

@@ -72,6 +72,11 @@ public class ToggleColorInversionPreferenceFragment extends
switchPreference.setTitle(R.string.accessibility_display_inversion_switch_title);
}
@Override
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
shortcutPreference.setTitle(R.string.accessibility_display_inversion_shortcut_title);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View File

@@ -167,6 +167,11 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
switchPreference.setTitle(R.string.accessibility_daltonizer_primary_switch_title);
}
@Override
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
shortcutPreference.setTitle(R.string.accessibility_daltonizer_shortcut_title);
}
@Override
int getUserShortcutTypes() {
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),

View File

@@ -284,7 +284,14 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
abstract int getUserShortcutTypes();
protected void updateToggleServiceTitle(SettingsMainSwitchPreference switchPreference) {
switchPreference.setTitle(R.string.accessibility_service_primary_switch_title);
final CharSequence title =
getString(R.string.accessibility_service_primary_switch_title, mPackageName);
switchPreference.setTitle(title);
}
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
final CharSequence title = getString(R.string.accessibility_shortcut_title, mPackageName);
shortcutPreference.setTitle(title);
}
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
@@ -434,8 +441,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
mShortcutPreference.setKey(getShortcutPreferenceKey());
mShortcutPreference.setOnClickCallback(this);
final CharSequence title = getString(R.string.accessibility_shortcut_title, mPackageName);
mShortcutPreference.setTitle(title);
updateShortcutTitle(mShortcutPreference);
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
generalCategory.addPreference(mShortcutPreference);

View File

@@ -154,6 +154,11 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
switchPreference.setTitle(R.string.reduce_bright_colors_preference_title);
}
@Override
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
shortcutPreference.setTitle(R.string.reduce_bright_colors_shortcut_title);
}
@Override
int getUserShortcutTypes() {
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),

View File

@@ -396,6 +396,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends
generalCategory.addPreference(mShortcutPreference);
}
@Override
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
shortcutPreference.setTitle(R.string.accessibility_screen_magnification_shortcut_title);
}
@Override
protected void updateShortcutPreference() {
final int shortcutTypes = PreferredShortcuts.retrieveUserShortcutType(getPrefContext(),