Merge "Uses placeholder and percentage formatter for seek bar state strings." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
b041a687ca
@@ -13366,9 +13366,9 @@
|
||||
<!-- Summary of the Live Caption enabled state. -->
|
||||
<string name="live_caption_enabled">On</string>
|
||||
<!-- State description for the Audio Balance seek bar, with left reported before right. -->
|
||||
<string name="audio_seek_bar_state_left_first">Audio %1$d%% left, %2$d%% right</string>
|
||||
<string name="audio_seek_bar_state_left_first">Audio <xliff:g id="percent_left">%1$s</xliff:g> left, <xliff:g id="percent_right">%2$s</xliff:g> right</string>
|
||||
<!-- State description for the Audio Balance seek bar, with right reported before left. -->
|
||||
<string name="audio_seek_bar_state_right_first">Audio %1$d%% right, %2$d%% left</string>
|
||||
<string name="audio_seek_bar_state_right_first">Audio <xliff:g id="percent_right">%1$s</xliff:g> right, <xliff:g id="percent_left">%2$s</xliff:g> left</string>
|
||||
|
||||
<!-- Warning text about the visibility of device name. [CHAR LIMIT=NONE] -->
|
||||
<string name="about_phone_device_name_warning">Your device name is visible to apps you installed. It may also be seen by other people when you connect to Bluetooth devices, connect to a Wi-Fi network or set up a Wi-Fi hotspot.</string>
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.widget.SeekBar;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
/**
|
||||
* A custom seekbar for the balance setting.
|
||||
@@ -178,10 +179,12 @@ public class BalanceSeekBar extends SeekBar {
|
||||
== LAYOUT_DIRECTION_RTL;
|
||||
final int rightPercent = (int) (100 * (progress / max));
|
||||
final int leftPercent = 100 - rightPercent;
|
||||
final String rightPercentString = Utils.formatPercentage(rightPercent);
|
||||
final String leftPercentString = Utils.formatPercentage(leftPercent);
|
||||
if (rightPercent > leftPercent || (rightPercent == leftPercent && isLayoutRtl)) {
|
||||
return context.getString(resIdRightFirst, rightPercent, leftPercent);
|
||||
return context.getString(resIdRightFirst, rightPercentString, leftPercentString);
|
||||
} else {
|
||||
return context.getString(resIdLeftFirst, leftPercent, rightPercent);
|
||||
return context.getString(resIdLeftFirst, leftPercentString, rightPercentString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.util.AttributeSet;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.testutils.shadow.ShadowSystemSettings;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -162,7 +163,8 @@ public class BalanceSeekBarTest {
|
||||
mProxySeekBarListener.onProgressChanged(mSeekBar, progress, true);
|
||||
|
||||
assertThat(mSeekBar.getStateDescription()).isEqualTo(
|
||||
mContext.getString(R.string.audio_seek_bar_state_left_first, 50, 50));
|
||||
mContext.getString(R.string.audio_seek_bar_state_left_first,
|
||||
Utils.formatPercentage(50), Utils.formatPercentage(50)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,7 +179,8 @@ public class BalanceSeekBarTest {
|
||||
mProxySeekBarListener.onProgressChanged(mSeekBar, progress, true);
|
||||
|
||||
assertThat(mSeekBar.getStateDescription()).isEqualTo(
|
||||
mContext.getString(R.string.audio_seek_bar_state_right_first, 50, 50));
|
||||
mContext.getString(R.string.audio_seek_bar_state_right_first,
|
||||
Utils.formatPercentage(50), Utils.formatPercentage(50)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -189,7 +192,8 @@ public class BalanceSeekBarTest {
|
||||
mProxySeekBarListener.onProgressChanged(mSeekBar, progress, true);
|
||||
|
||||
assertThat(mSeekBar.getStateDescription()).isEqualTo(
|
||||
mContext.getString(R.string.audio_seek_bar_state_left_first, 75, 25));
|
||||
mContext.getString(R.string.audio_seek_bar_state_left_first,
|
||||
Utils.formatPercentage(75), Utils.formatPercentage(25)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,7 +205,8 @@ public class BalanceSeekBarTest {
|
||||
mProxySeekBarListener.onProgressChanged(mSeekBar, progress, true);
|
||||
|
||||
assertThat(mSeekBar.getStateDescription()).isEqualTo(
|
||||
mContext.getString(R.string.audio_seek_bar_state_right_first, 75, 25));
|
||||
mContext.getString(R.string.audio_seek_bar_state_right_first,
|
||||
Utils.formatPercentage(75), Utils.formatPercentage(25)));
|
||||
}
|
||||
|
||||
// method to get the center from BalanceSeekBar for testing setMax().
|
||||
|
||||
Reference in New Issue
Block a user