Merge "Create separate On/Off string resources for Vibration & haptics" into tm-dev

This commit is contained in:
Lais Andrade
2022-04-27 13:54:13 +00:00
committed by Android (Google) Code Review
3 changed files with 11 additions and 4 deletions

View File

@@ -5577,6 +5577,10 @@
<string name="accessibility_vibration_settings_title">Vibration &amp; haptics</string> <string name="accessibility_vibration_settings_title">Vibration &amp; haptics</string>
<!-- Summary for preference screen for configuring vibrations. [CHAR LIMIT=NONE] --> <!-- Summary for preference screen for configuring vibrations. [CHAR LIMIT=NONE] -->
<string name="accessibility_vibration_settings_summary">Control the vibration strength for different usages</string> <string name="accessibility_vibration_settings_summary">Control the vibration strength for different usages</string>
<!-- "Vibration & haptics" preference's state when enabled. This text is shown next to the "Vibration & haptics" preference title. [CHAR LIMIT=NONE] -->
<string name="accessibility_vibration_settings_state_on">On</string>
<!-- "Vibration & haptics" preference's state when disabled. This text is shown next to the "Vibration & haptics" preference title. [CHAR LIMIT=NONE] -->
<string name="accessibility_vibration_settings_state_off">Off</string>
<!-- Summary for vibration preference shown when it is disabled because the device is in silent mode. [CHAR LIMIT=NONE] --> <!-- Summary for vibration preference shown when it is disabled because the device is in silent mode. [CHAR LIMIT=NONE] -->
<string name="accessibility_vibration_setting_disabled_for_silent_mode_summary">Setting disabled because device is set to silent</string> <string name="accessibility_vibration_setting_disabled_for_silent_mode_summary">Setting disabled because device is set to silent</string>
<!-- Title for the category of preferences to configure device vibrations related to calls. [CHAR LIMIT=NONE] --> <!-- Title for the category of preferences to configure device vibrations related to calls. [CHAR LIMIT=NONE] -->

View File

@@ -44,6 +44,9 @@ public class VibrationPreferenceController extends BasePreferenceController {
public CharSequence getSummary() { public CharSequence getSummary() {
final boolean isVibrateOn = Settings.System.getInt(mContext.getContentResolver(), final boolean isVibrateOn = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.VIBRATE_ON, ON) == ON; Settings.System.VIBRATE_ON, ON) == ON;
return mContext.getText(isVibrateOn ? R.string.switch_on_text : R.string.switch_off_text); return mContext.getText(
isVibrateOn
? R.string.accessibility_vibration_settings_state_on
: R.string.accessibility_vibration_settings_state_off);
} }
} }

View File

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