Revert "Remove duplicate strings."

Revert submission 19748582-settings_yesno

Reason for revert: Common strings in English could be translated into different strings in other languages.

Reverted changes: /q/submissionid:19748582-settings_yesno

Bug: 272603842
Test: build and open Settings app
Test: atest SettingsRoboTests
Change-Id: Iaad301c5513478fb95e40987ea3ccb4f923d71fa
This commit is contained in:
Lifu Tang
2023-03-15 21:37:02 +00:00
committed by Kweku Adams
parent 36d78f8fe0
commit caa1b51ef2
70 changed files with 221 additions and 113 deletions

View File

@@ -194,7 +194,7 @@ public class AccessibilitySettingsTest {
mServiceInfo, SERVICE_ENABLED);
assertThat(summary).isEqualTo(
mContext.getString(R.string.on));
mContext.getString(R.string.accessibility_summary_state_enabled));
}
@Test
@@ -205,13 +205,13 @@ public class AccessibilitySettingsTest {
mServiceInfo, SERVICE_DISABLED);
assertThat(summary).isEqualTo(
mContext.getString(R.string.off));
mContext.getString(R.string.accessibility_summary_state_disabled));
}
@Test
public void getServiceSummary_enableServiceAndHasSummary_showsEnabledSummary() {
final String service_enabled = mContext.getString(
R.string.on);
R.string.accessibility_summary_state_enabled);
doReturn(DEFAULT_SUMMARY).when(mServiceInfo).loadSummary(any());
final CharSequence summary = AccessibilitySettings.getServiceSummary(mContext,
@@ -225,7 +225,7 @@ public class AccessibilitySettingsTest {
@Test
public void getServiceSummary_disableServiceAndHasSummary_showsCombineDisabledSummary() {
final String service_disabled = mContext.getString(
R.string.off);
R.string.accessibility_summary_state_disabled);
doReturn(DEFAULT_SUMMARY).when(mServiceInfo).loadSummary(any());
final CharSequence summary = AccessibilitySettings.getServiceSummary(mContext,

View File

@@ -80,7 +80,7 @@ public final class AccessibilityUtilTest {
final CharSequence result = AccessibilityUtil.getSummary(mContext, SECURE_TEST_KEY);
assertThat(result)
.isEqualTo(mContext.getText(R.string.on));
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_on));
}
@Test
@@ -90,7 +90,7 @@ public final class AccessibilityUtilTest {
final CharSequence result = AccessibilityUtil.getSummary(mContext, SECURE_TEST_KEY);
assertThat(result)
.isEqualTo(mContext.getText(R.string.off));
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
}
@Test
@@ -98,7 +98,7 @@ public final class AccessibilityUtilTest {
final CharSequence result = AccessibilityUtil.getSummary(mContext, SECURE_TEST_KEY);
assertThat(result)
.isEqualTo(mContext.getText(R.string.off));
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
}
@Test

View File

@@ -60,7 +60,7 @@ public class AutoclickPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, OFF);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.off));
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
}
@Test

View File

@@ -58,7 +58,7 @@ public class CaptioningPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, ON);
assertThat(mController.getSummary()).isEqualTo(
mContext.getText(R.string.on));
mContext.getText(R.string.accessibility_feature_state_on));
}
@Test
@@ -67,6 +67,6 @@ public class CaptioningPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
assertThat(mController.getSummary()).isEqualTo(
mContext.getText(R.string.off));
mContext.getText(R.string.accessibility_feature_state_off));
}
}

View File

@@ -52,7 +52,7 @@ public class ColorInversionPreferenceControllerTest {
DISPLAY_INVERSION_ENABLED, State.ON);
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.on))).isTrue();
mContext.getText(R.string.accessibility_feature_state_on))).isTrue();
}
@Test
@@ -61,7 +61,7 @@ public class ColorInversionPreferenceControllerTest {
DISPLAY_INVERSION_ENABLED, State.OFF);
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.off))).isTrue();
mContext.getText(R.string.accessibility_feature_state_off))).isTrue();
}
@Retention(RetentionPolicy.SOURCE)

View File

@@ -50,7 +50,7 @@ public class DaltonizerPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, ON);
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.on))).isTrue();
mContext.getText(R.string.accessibility_feature_state_on))).isTrue();
}
@Test
@@ -59,6 +59,6 @@ public class DaltonizerPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, OFF);
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.off))).isTrue();
mContext.getText(R.string.accessibility_feature_state_off))).isTrue();
}
}

View File

@@ -64,13 +64,13 @@ public class MagnificationGesturesPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON);
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.on));
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_on));
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF);
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.off));
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_off));
}
@Test

View File

@@ -89,13 +89,13 @@ public class MagnificationNavbarPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, ON);
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getText(R.string.on));
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_on));
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, OFF);
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getText(R.string.off));
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
}
@Test

View File

@@ -92,7 +92,7 @@ public class VibrationPreferenceControllerTest {
controller.updateState(mPreference);
assertThat(mPreference.getSummary().toString()).isEqualTo(
mContext.getString(R.string.on));
mContext.getString(R.string.accessibility_vibration_settings_state_on));
}
@Test
@@ -103,7 +103,7 @@ public class VibrationPreferenceControllerTest {
controller.updateState(mPreference);
assertThat(mPreference.getSummary().toString()).isEqualTo(
mContext.getString(R.string.on));
mContext.getString(R.string.accessibility_vibration_settings_state_on));
}
@Test
@@ -114,7 +114,7 @@ public class VibrationPreferenceControllerTest {
controller.updateState(mPreference);
assertThat(mPreference.getSummary().toString()).isEqualTo(
mContext.getString(R.string.off));
mContext.getString(R.string.accessibility_vibration_settings_state_off));
}
private VibrationPreferenceController createPreferenceController() {

View File

@@ -73,7 +73,7 @@ public class BackupDataPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.on));
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_on));
}
@Test
@@ -83,7 +83,7 @@ public class BackupDataPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.off));
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_off));
}
@Test

View File

@@ -90,7 +90,7 @@ public class BackupSettingsHelperTest {
String backupSummary = mBackupSettingsHelper.getSummary();
assertThat(backupSummary).isEqualTo(mContext.getString(R.string.on));
assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_on));
}
@Test
@@ -100,7 +100,7 @@ public class BackupSettingsHelperTest {
String backupSummary = mBackupSettingsHelper.getSummary();
assertThat(backupSummary).isEqualTo(mContext.getString(R.string.off));
assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_off));
}
@Test

View File

@@ -132,7 +132,7 @@ public class BluetoothSummaryUpdaterTest {
mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF);
verify(mListener).onSummaryChanged(mContext.getString(R.string.off));
verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disabled));
}
@Test
@@ -197,12 +197,12 @@ public class BluetoothSummaryUpdaterTest {
mShadowBluetoothAdapter.setEnabled(false);
mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF);
verify(mListener).onSummaryChanged(mContext.getString(R.string.off));
verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disabled));
// Turning ON means not enabled
mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_TURNING_ON);
// There should still be only one invocation of disabled message
verify(mListener).onSummaryChanged(mContext.getString(R.string.off));
verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disabled));
mShadowBluetoothAdapter.setEnabled(true);
mDeviceConnected[0] = false;

View File

@@ -92,13 +92,13 @@ public class NfcAndPaymentFragmentControllerTest {
public void getSummary_nfcOn_shouldProvideOnSummary() {
mShadowNfcAdapter.setEnabled(true);
assertThat(mController.getSummary().toString()).contains(
mContext.getString(R.string.on));
mContext.getString(R.string.switch_on_text));
}
@Test
public void getSummary_nfcOff_shouldProvideOffSummary() {
mShadowNfcAdapter.setEnabled(false);
assertThat(mController.getSummary().toString()).contains(
mContext.getString(R.string.off));
mContext.getString(R.string.switch_off_text));
}
}

View File

@@ -109,7 +109,7 @@ public class AutoBrightnessPreferenceControllerTest {
mController.setChecked(true);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.on));
.isEqualTo(mContext.getText(R.string.auto_brightness_summary_on));
}
@Test
@@ -117,7 +117,7 @@ public class AutoBrightnessPreferenceControllerTest {
mController.setChecked(false);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.off));
.isEqualTo(mContext.getText(R.string.auto_brightness_summary_off));
}
@Test

View File

@@ -86,9 +86,9 @@ public class SmartAutoRotatePreferenceControllerTest {
doReturn(PACKAGE_NAME).when(mPackageManager).getRotationResolverPackageName();
doReturn(PackageManager.PERMISSION_GRANTED).when(mPackageManager).checkPermission(
Manifest.permission.CAMERA, PACKAGE_NAME);
when(mContext.getString(R.string.off))
when(mContext.getString(R.string.auto_rotate_option_off))
.thenReturn("Off");
when(mContext.getString(R.string.on))
when(mContext.getString(R.string.auto_rotate_option_on))
.thenReturn("On");
when(mContext.getString(R.string.auto_rotate_option_face_based))
.thenReturn("On - Face-based");

View File

@@ -67,7 +67,7 @@ public class OneHandedEnablePreferenceControllerTest {
OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, true);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.on));
.isEqualTo(mContext.getText(R.string.switch_on_text));
}
@Test
@@ -75,6 +75,6 @@ public class OneHandedEnablePreferenceControllerTest {
OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, false);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.off));
.isEqualTo(mContext.getText(R.string.switch_off_text));
}
}

View File

@@ -137,7 +137,7 @@ public class PreventRingingParentPreferenceControllerTest {
VOLUME_HUSH_OFF);
mController.updateState(mPreference);
assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getText(
R.string.off));
R.string.switch_off_text));
}
@Test

View File

@@ -97,7 +97,7 @@ public class SpellCheckerPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mAppContext.getString(R.string.off));
.isEqualTo(mAppContext.getString(R.string.switch_off_text));
}
@Test

View File

@@ -97,7 +97,7 @@ public class LocationForWorkPreferenceControllerTest {
verify(mUserManager)
.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, false, mUserHandle);
verify(mPreference).setSummary(R.string.on);
verify(mPreference).setSummary(R.string.switch_on_text);
}
@Test
@@ -109,7 +109,7 @@ public class LocationForWorkPreferenceControllerTest {
verify(mUserManager)
.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, mUserHandle);
verify(mPreference).setSummary(R.string.off);
verify(mPreference).setSummary(R.string.switch_off_text);
}
@Test
@@ -147,7 +147,7 @@ public class LocationForWorkPreferenceControllerTest {
mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
verify(mPreference).setEnabled(true);
verify(mPreference).setSummary(R.string.on);
verify(mPreference).setSummary(R.string.switch_on_text);
}
@Test

View File

@@ -53,7 +53,7 @@ public class TopLevelLocationPreferenceControllerTest {
public void getSummary_whenLocationIsOff_shouldReturnStringForOff() {
mLocationManager.setLocationEnabledForUser(false, android.os.Process.myUserHandle());
assertThat(mController.getSummary()).isEqualTo(
mContext.getString(R.string.off));
mContext.getString(R.string.location_settings_summary_location_off));
}
@Test

View File

@@ -74,7 +74,7 @@ public class AdaptiveConnectivityPreferenceControllerTest {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1);
assertThat(mController.getSummary()).isEqualTo(mContext.getString(R.string.on));
assertThat(mController.getSummary()).isEqualTo(mContext.getString(R.string.switch_on_text));
}
@Test
@@ -83,6 +83,6 @@ public class AdaptiveConnectivityPreferenceControllerTest {
Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 0);
assertThat(mController.getSummary())
.isEqualTo(mContext.getString(R.string.off));
.isEqualTo(mContext.getString(R.string.switch_off_text));
}
}

View File

@@ -224,7 +224,7 @@ public class PrivateDnsPreferenceControllerTest {
when(lp.getValidatedPrivateDnsServers()).thenReturn(NON_EMPTY_ADDRESS_LIST);
updateLinkProperties(lp);
mController.updateState(mPreference);
verify(mPreference).setSummary(getResourceString(R.string.on));
verify(mPreference).setSummary(getResourceString(R.string.private_dns_mode_on));
reset(mPreference);
lp = mock(LinkProperties.class);

View File

@@ -141,7 +141,7 @@ public class TetherPreferenceControllerTest {
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"456"});
mController.updateSummary();
verify(mPreference).setSummary(R.string.off);
verify(mPreference).setSummary(R.string.switch_off_text);
}
@Test
@@ -172,7 +172,7 @@ public class TetherPreferenceControllerTest {
ReflectionHelpers.getField(mController, "mAirplaneModeObserver");
observer.onChange(true, Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON));
verify(mPreference).setSummary(R.string.off);
verify(mPreference).setSummary(R.string.switch_off_text);
}
@Test

View File

@@ -145,7 +145,7 @@ public class PrintSettingsPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.off));
.isEqualTo(mContext.getString(R.string.print_settings_summary_no_service));
}
@Test

View File

@@ -76,7 +76,7 @@ public class ScreenPinningPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.off));
.isEqualTo(mContext.getString(R.string.switch_off_text));
}
@Test
@@ -87,7 +87,7 @@ public class ScreenPinningPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.on));
.isEqualTo(mContext.getString(R.string.switch_on_text));
}
@Test

View File

@@ -55,8 +55,8 @@ public class SwitchBarTest {
@Test
public void cycleChecked_defaultLabel_shouldUpdateTextAndBackground() {
final int defaultOnText = R.string.on;
final int defaultOffText = R.string.off;
final int defaultOnText = R.string.switch_on_text;
final int defaultOffText = R.string.switch_off_text;
assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
.isEqualTo(mContext.getString(defaultOffText));

View File

@@ -110,7 +110,7 @@ public class WifiSummaryUpdaterTest {
mWifiTracker.enabled = false;
assertThat(mSummaryUpdater.getSummary())
.isEqualTo(mContext.getString(R.string.off));
.isEqualTo(mContext.getString(R.string.switch_off_text));
}
@Test